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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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?
ASKER
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
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
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?