Add sequence number for records

G

Guest

I need to add a sequence number for multiple records with the same primary ID.

Basically, I have multiple entries in a table for the same primary key (in
this case a customer ID). I need to add a field to the table and update it
with the record number for the customer ID.

For example, customer ID 12345 has 4 entries in the table. In the new
field, 'EventNumber', I want to number the events 1, 2, 3 and 4 respectively
(in order by a date/time field that already exists).

Anybody know how I can do this? Thanks!
 
G

Guest

You can do that using some VBA in the report
1. On the report declaretion declare a vaiable
Dim MyCount as Integer
2. Create a group header for the Customer Id, using the grouping and sorting.
3. On the On format event of the customer id write the code
MyCount = 0
4. On the On format event of the details section, where you list the
customers write the code
MyCount = MyCount + 1
Me.EventNumber = MyCount
 
G

Guest

Sorry Paul, I should have noticed that you posted the request in Queries and
not report.
The answer I gave you is to use in a report and not in a query.
 

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