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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Autonumbering 1

Status
Not open for further replies.

Dennisje

Technical User
Dec 23, 2003
3
NL
I want to write a macro instead of using autonumbering. Can anyone provide me de settings of such a macro?
 
put this code in the on current event of your form
this example refers
to a table called tblCompany
with primary key ID

If Me.NewRecord Then

Me!ID.DefaultValue = Nz(DMax("[ID]", "tblCompany"), 0) + 1
End If



Best of luck and merry christmas

Jimmy
 
Thanks very much for the solution and merry christmas to you too....
 
Jimmy,

The NZ reference...is that a function? This is a great tip...have a star!

-Patrick

Nine times out of ten, the simplest solution is the best one.
 
Patrick
The NZ function is the null to zero built in function.

cheers

Jimmy
 
Jimmy, thanks for your advise but it doesn't seem to work. I get a message: The expression you entered contains invalid syntax. You may have entered an operand without an operator. I used the data type: Number and the same field name as you used in your example. Is that ok?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top