+1 function

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?
 
J

John Vinson

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

D McM

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
 
R

Rick Brandt

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top