Search code examples
ms-accessvbams-access-2016

How to position specific record(s) at top of list


I am working with all currency types and rates in a query. Because they are the most popular, is it possible to have USD and EUR positioned at the top of a query list before displaying the rest of the currency codes in alphabetical order?


Solution

  • Let's say your table is called tblRate having two columns, Rate and Curr. Create a query that uses the Switch function to assign a ranking order to USD (ranking order 1), EUR (raking order 2). Assign ranking order 3 to all other currencies using the Nz function. In your query you order by rank, next by currency.

    SQL view:

    SELECT Rate, Curr
    FROM tblRate
    ORDER BY Nz(Switch(Curr = "USD",1, Curr = "EUR",2),3), Curr