Link to home
Start Free TrialLog in
Avatar of Svgmassive
Svgmassive

asked on

Add sequential numbering at runtime

i would like to add sequential numbering to a filed headquarters at runtime in a ms access query (vba)
ASKER CERTIFIED SOLUTION
Avatar of Daniel Pineault
Daniel Pineault

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
There are a number of different ways to get sequential numbers (check here for a good survey of some of them), depending on how your data is structured and what you want to do with them.

Can you tell us more about your need?

Do you want to add a number to a "Headquarters" field?
Do you want a column of sequential numbers to appear in query results?  Or on a form or a report?
Avatar of Svgmassive
Svgmassive

ASKER

Do you want to add a number to a "Headquarters" field?.... no
Do you want a column of sequential numbers to appear in query results?  Or on a form or a report?.. yes
When you assign numbers at runtime, the number assigned to any given record could be different today than it was yesterday.  Is that a problem?
no it's not pat
Good.  The link Danial provided will provide what you need.
I am pretty sure that Gustav's solution is top notch...i haven't have the chance to use it but he is doing excellent code
Nevertheless if you want to add your own Numbering here is some simple Numbering code
Public Function SimpleSeq()
Dim rst As DAO.Recordset
Dim myNumbering As Integer
myNumbering = 1
Set rst = CurrentDb.OpenRecordset("YOUR_QUERY")
With rst
While Not .EOF
    .Edit
    .Fields("MySequentialNumbering") = myNumbering
    .Update
    myNumbering = myNumbering + 1
    .MoveNext
Wend
End With
rst.Close
Set rst = Nothing
End Function

Open in new window