This seems to also be a solution to my situtation; does it
appear so to you? When I attempt to translate your example
to my query I'm getting a syntax error, so evidently I
don't guite get it yet. Perhaps you could clarify your
example for the SQL-challenged?
I am creating a waiting list with the position on the list
based on the date and time the record was added. I've done
that using a running-sum counter textbox in a report. In
order to generate an alphabetical listing of these people,
I have to analyze the report in Excel and sort the
spreadsheet based on the client's name.
While this gets the job done, it's a bit of a kludge. I'd
prefer to set a calculated field within the query so the
report can be sorted any way I like (position, name, zip
code, etc) without having to leave Access (and without
having to become a VB programmer).
I found something of a solution in the KB
<
http://support.microsoft.com/default.aspx?scid=kb;en-us;
199679>, but hope a simpler solution exists! I'm certain
that if it does, someone here will be able to enlighten me!
Thanks,
-Bob
-----Original Message-----
There is not a nice way to do this, but if you don't mind a read-only result
(e.g. if it's going to a report), you could use a subquery to count the
number of records ahead of this one.
You type the subquery into a fresh column in the Field row in query design
view. Something like this:
Rank: (SELECT (Count([ID]) + 1) AS Rank FROM MyTable AS Dupe WHERE (Dupe.ID
< MyTable.ID))
Where there is a tie, you get typical ranking results, e. g.:
1
2
2
4
5
If you need the records to be updatable, you can use DCount() to create the
calculated field, but it will be very slow.
I am trying to include a row number in a query. Is this
possible?
I am compiling top 10's of product for 4 individual years
and in order to link each individual query I need to
calcaluate a position (position 1 in 2002 will link to
position 1 in year 2001 etc)
Is there a way to do this without having to create tables
with an autonumber field?
Any help would be appreciated
K