ListBox - Just counting rows

H

H. Martins

I have a ListBox in a report.

The most left column must contain just the row number of the list ...
1, 2, 3, etc.

I could create an extra field and fill it with numbers (1, 2, 3) just
in records belonging to the respective query, but if someone else
opens a similar query somewhere else I would have some sort of
conflict (I think).

Is there any simpler way of doing it? (Creating some sort of 'local
column?).

H. Martins
 
M

Marshall Barton

H. Martins said:
I have a ListBox in a report.

The most left column must contain just the row number of the list ...
1, 2, 3, etc.

I could create an extra field and fill it with numbers (1, 2, 3) just
in records belonging to the respective query, but if someone else
opens a similar query somewhere else I would have some sort of
conflict (I think).

Is there any simpler way of doing it? (Creating some sort of 'local
column?).


The general answer to that is to do the row numbering in a
calculated field in the list box's row source query. Use a
subquery to do the calculation The subquery requires that
the records you want to number have a field that can be used
to uniquely sort the records. Then general idea would be
along these lines:

RowNum: (SELECT Count(*) FROM something As X
WHERE X.sortfield <= something.sortfield)

OTOH, you did say that you were doing this in a report.
Using a list box in a report is a poor way to present data,
Instead you should create another report that display the
data you currently have in the list box and just use a text
box with the expression =1 and RunningSum set to Over Group
or Over All. Then drop this new report on your current
report )as a subreport) in place of the list box.
 

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