Automatically increase Order Number

C

Cody

I've created a form to enter orders into. I figured out how to use the
autofill function so that each new record pulls the number from the previous
record. But what i want to do is have the order number automatically filled
in, but increased by one. How can this be done?
 
K

Karen

This is probably the roughest code around but I know it works. I have it
behind a button 'New Form' on a form.

Dim refvar As Integer
Dim mydate

DoCmd.Echo False
DoCmd.Requery

DoCmd.GoToRecord , , acLast 'go to last record in table
refvar = REFERENCE + 1 'add 1 to reference
DoCmd.GoToRecord , , acNewRec 'append new record to table
REFERENCE = refvar 'fill in refence
mydate = Now() 'remember today's date
Me![refdate] = mydate 'fill in refdate with todays date
refdate.SetFocus 'set focus on refdate

'save the new record
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

DoCmd.Echo True
 
Top