Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Count records in descending order

Status
Not open for further replies.

icsupt

MIS
Jun 14, 2004
150
US
Right now I have a report with 20 records. I want to number the records in the report in descending order. So, beside the first record, I want to have 20, the next record would be 19, etc.

Thanks in advance.
 
a loop that decrements should give you what you want.

Dim rst as recordset
Dim i as integer

i = 0

for i = (rst.recordcount) to i = 0

rst.[record_number_field].value = i
i = i - 1

Next

Hope this helps





 
Hi,
It is always best to base your reports on a query, because alot can be accomplished within the query. For example, you can sort all the records in descending order based on a particular field value, such as OrderTotal or YTDPurchases.
HTH, Randy Smith (MCP)
 
Put a text box in your detail section, call it "txtNumber" make it's Control Source "=-1" (no quotes) and set property RUNNING SUM to OVER GROUP. You can make this VISIBLE=NO eventually. If you look now you will see it will count -1,-2,-3, etc.

Put a second text box in your detail section, set it to count the number of records in your table or query, minus the count in txtNumber:


=DCount("EmpNo","tblEmployee")-[txtNumber]+1

You have to sub in a field name for "EmpNo" and your table/query name for "tblEmployees". This is the text box you want to display.

g

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top