Autonumber maxValue + 1 in a form

  • Thread starter Thread starter Jan T.
  • Start date Start date
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
 
Me!FIELDNAME = DMax("[FIELDNAME]", "[TABLENAME]") + 1

in the forms "before insert" event
 
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
 
Back
Top