Dmax for empty table

Azhar.iq

Registered User.
Local time
Today, 20:32
Joined
Apr 10, 2015
Messages
18
How do i use DMax() function instead of Autonumber, since the table is empty and it wont know what to do with Dmax() + 1 for next record?

E.g I have a new table Customer_details which contains

customerID
customerName
Age

now if i enter data through forms, i want the CustomerID to be incremental for each new record, so i can use Dmax() function. But since the table is empty how can i tell the form, through VBA that if it is null store 1 else store Dmax("CustomerID", "Customer_Details") + 1
 
DMax by default gives you a Null if nothing is there. So you can use the Nz function, so.
Code:
Nz(DMax("CustomerID", "Customer_Details"), 0) + 1
This will give you 1, if there is nothing in the table
 
Thanks, it worked.
 

Users who are viewing this thread

Back
Top Bottom