How to add a ranking field to my access query

PaulCL

New Member
Joined
Jul 9, 2014
Messages
43
How to I add a ranking field to my access query. I have five fields, but would like to add a 6th field to rank the results of the query i.e. rank each market by total volume.
Tks :)

Market:MLSFirmNameNo OfficesTotal UnitsTotal VolumeRank?

<tbody>
</tbody>
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
i have a query to sort the table, then the code goes thru marking the rankings....
usage: in a button click
RANK "qsMyQuery"

Code:
Public Sub Rank(pvQry)
Dim rst   'As Recordset
Dim lNum As Long


lNum = 1
Set rst = CurrentDb.OpenRecordset(pvQry)
With rst
    While Not .EOF
         .Fields("Rank") = lNum
         .Update
         lNum = lNum + 1
         
         .MoveNext
    Wend
End With
Set rst = Nothing
End Sub
 
Upvote 0

Forum statistics

Threads
1,221,846
Messages
6,162,376
Members
451,760
Latest member
samue Thon Ajaladin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top