Generating sequential numbers

A

Adam

Is there any way I can use a query to sort a table and then, using an update
query, generate a sequential number based on the sort order I have chosen?
In other words, I sort the table by whatever method I choose, and then in
that sort order, a field in the table would have the value 1 for the first
record, 2 for the second, and so on.

This seems like a very simple thing to do, and I could no doubt write some
very simple VBA code to do it, but I can't help feeling I ought to be able
to do it with a query. Any ideas?

Many thanks
 
M

Michel Walsh

Hi,


With JET? Insert the sorted rows in a new table having a
(non-replicable, incrementing) AUTONUMBER field. Do not specify a value for
the autonumber field in your INSERT INTO statement, but be sure to include
the ORDER BY clause in the SELECT statement.

Hoping it may help
Vanderghast, Access MVP
 
A

Adam

Many thanks, that works a treat.

Adam

Michel Walsh said:
Hi,


With JET? Insert the sorted rows in a new table having a
(non-replicable, incrementing) AUTONUMBER field. Do not specify a value for
the autonumber field in your INSERT INTO statement, but be sure to include
the ORDER BY clause in the SELECT statement.

Hoping it may help
Vanderghast, Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top