query index

  • Thread starter Thread starter AccessMan
  • Start date Start date
A

AccessMan

I would like to have a query field that displays the index position of each
returned row. Is there a way to do this?

Thanks!
 
Can you explain a little more what you mean by "index position"?

Do you mean you want to display a number indicating that this is the nth
(1,2,3,4,5, ...) record displayed in this set of data?

If so, why? That is where do you intend to use the information? In a
report? On a form? When you display the query in datasheet view?

In a report, it is simple to do so.
On a continuous form, it is a bit more complex.
In datasheet view of a query, it is yet more complex.


'====================================================
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
 
John, I was wondering about the purpose of this too. But regardless of that,
from an academic perspective, wouldn't the natural index be represented
by the AbsolutePosition value when looping through a recordset based on
the table with no sort assigned?

How one would pull that into a query is a question, and again, I can't figure
out what real value it would be.
 
Yes, by index position I mean the 'row' number of the query output.
Unfortunately, I need to use it in a datasheet view of a query.
 
The following URL may help
http://www.lebans.com/rownumber.htm

Download the sample database and copy the vba module into your
application. Then use the Serialize function to generate a row number.

Note that the row number relies on the value of the field used being
unique within the recordset. If you have two records with the same
value, you are going to get two records with the same position number.

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
 
Back
Top