Number rows in a query

ready4data

Registered User.
Local time
Today, 21:30
Joined
Jun 4, 2002
Messages
39
I'm trying to display a number in the first field of a query for each row in the query starting with the number 3 and increment the number by 1 for each additional row. I've seen queries of running totals but what would I total on?
Any help is appreciated.
Scott
 
This will work, though its not very elegant...

Original table Customer, Table2 is the new table.

Copy Design of customer as new table Table2 and add a new field called say, RowCounter and set the field to Autonumber.

Add two junk records to this table2 and then delete them. (Now the autonumber will start from 3 (when you append data)

Write your query in the format:-
(for simplicity, I'm just updating for the Addr field here where field contains "Street")...

UPDATE Customers LEFT JOIN Table2 ON Customers.CustID = Table2.CustID SET Table2.Addr = [customers].[Addr]
WHERE (((Table2.Addr) Like "*Street*"));

When this runs, you will have your queried data in the new table with a rowcounter,starting at count of 3 and incrementing by 1.

Then just run a query on the new table, (Table2) to show your results plus row number.

NB. This will update or append, but you may need to clear out all data from Table2 (except the autonumber field), each time prior to running this.

HTH, but as i said 'Not very elegant'!!
 

Users who are viewing this thread

Back
Top Bottom