Autonumber maxValue + 1 in a form

J

Jan T.

I use Access 2003 and I have a form without a regular Auto number.
This because the data is imported from Excel into Access with
thousands of records. However many record numbers are missing in
between the records.

Now I want my form to generate a custom Auto number when going to
(making) a New Record.
I thought the best would be to use vba and find max value for say
"CaseId" and add one. Then the code should put that number in the text
box and set focus on the next text box.

Any suggestions for vba code here?

Thank you very much in advance.

Regards
Jan
 
S

scubadiver

Me!FIELDNAME = DMax("[FIELDNAME]", "[TABLENAME]") + 1

in the forms "before insert" event
 
J

Jan T.

Me!FIELDNAME = DMax("[FIELDNAME]", "[TABLENAME]") + 1

in the forms "before insert" event

--

http://www.ready4mainstream.ny911truth.org/index.html



Jan T. said:
I use Access 2003 and I have a form without a regular Auto number.
This because the data is imported from Excel into Access with
thousands of records. However many record numbers are missing in
between the records.
Now I want my form to generate a custom Auto number when going to
(making) a New Record.
I thought the best would be to use vba and find max value for say
"CaseId" and add one. Then the code should put that number in the text
box and set focus on the next text box.
Any suggestions for vba code here?
Thank you very much in advance.
Regards
Jan- Skjul sitert tekst -

- Vis sitert tekst -

Thank you. That's exactly what I wanted.

Regards
Jan
 

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