Ref:Create Autonumber

K

Kim

I read the entry the used the DMAX function to
autoincrement, I tried to use this in my program:
rst!ReferenceNumber = DMax([ReferenceNumber]) + 1

The program highlights DMax and says Argument Not Optional

Any help?
 
K

Kelvin

You need to include the name of the table that [ReferenceNumber] is in.

DMax([RefernceNumber],"NameOfTable")+1

Kelvin
 
J

John Vinson

I read the entry the used the DMAX function to
autoincrement, I tried to use this in my program:
rst!ReferenceNumber = DMax([ReferenceNumber]) + 1

The program highlights DMax and says Argument Not Optional

The DMax function has two required arguments, both text strings: the
name of the field for which you want to find the maximum value, and
the name of the Query or Table containing that field. The third
optional argument is another text string, a valid SQL WHERE clause
without the word WHERE limiting which records are searched.

If your table is named MyTable, the syntax would be

rst!ReferenceNumber = DMax("[ReferenceNumber]", "MyTable") + 1
 
S

Steve Schapel

Kim,

.... and you need to put ""s around the field name...
DMax("[ReferenceNumber]","NameOfTable") + 1

- Steve Schapel, Microsoft Access MVP
 

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