Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access 2007 - Need Help Auto-Incrementing Number on Form

Status
Not open for further replies.

lrdave36

Technical User
Jan 6, 2010
77
US
Hey guys,I have a field on a form called tracking that is a bound text box. When the user goes to add a record to the form, I want this text box to automatically populate with the next tracking sequential tracking number in the table.


I have an old Access 2003 database that accomplished this task, but I can't figure out how they did it. They have a text box called text20 for the tracking number, and an unbound text box called text58. I clicked view code, and found this:

Private Sub Command60_Click()
Recordset.MoveLast
Text58 = Text20
Recordset.AddNew
Text20 = Text58 + 1

End Sub
Private Sub Command61_Click()
Recordset.MovePrevious
Recordset.MoveNext
Recordset.MoveNext
End Sub


It looks like this code is doing the auto-increment, but I don't know how to implement it into my form. How does Access know what the previous tracking number was in the table?




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top