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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

numbering the records in a query result

Status
Not open for further replies.

scott6117

Technical User
Feb 25, 2003
5
US
Is there a way to number the results of a query? I import data into a table each week and then generate a query based on the table. I need the results of the query to be numbered from 1 to XXXX. I've tried to use the autonumber datatype in the table but the count doesn't reset to 1 each time the new data is imported. Reseting the autonumber field in the table would also work.

Thanks
Scott C.
 
How about creating a new table each time instead of appending to an old table? Each time you get done delete the table. Then import the data to a new table with the same name.
 
The incrementing function is a good idea, but I like to do things in the query where possible. You could create a counter field as something like:

counter: [id]-dfirst("[id]","
") + 1

That is pretty fast and is easier for others to understand.

You can also reset the autonumber field by emptying the table and then compacting the database, but that is a manual process as Access closes the database when you compact it.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top