+1 function

  • Thread starter Thread starter collier
  • Start date Start date
C

collier

I am creating a Records Tracking Database. I would like
for each record to be given a unique 5 digit number
assigned to it. How do I do a (+1) function in the "Log
Number" field, from one record to the next?
 
I am creating a Records Tracking Database. I would like
for each record to be given a unique 5 digit number
assigned to it. How do I do a (+1) function in the "Log
Number" field, from one record to the next?

If you do all your input in a Form, use the Form's BeforeInsert event:

Private Sub Form_BeforeInsert(Cancel as Integer)
Me!txtLogNumber = NZ(DMax("[Log Number]", "yourtablename")) + 1
End Sub
 
How & where do you enter the starting number?

thanks,
Katie

John Vinson said:
I am creating a Records Tracking Database. I would like
for each record to be given a unique 5 digit number
assigned to it. How do I do a (+1) function in the "Log
Number" field, from one record to the next?

If you do all your input in a Form, use the Form's BeforeInsert event:

Private Sub Form_BeforeInsert(Cancel as Integer)
Me!txtLogNumber = NZ(DMax("[Log Number]", "yourtablename")) + 1
End Sub
 
D McM said:
How & where do you enter the starting number?


Change to...

Me!txtLogNumber = NZ(DMax("[Log Number]", "yourtablename"),n) + 1

....where n is one less than the starting number you want.
 
Back
Top