Sequential Number Not Auto Number

  • Thread starter Thread starter Fred Webster
  • Start date Start date
F

Fred Webster

I am trying to generate a new number in a form.
I would like to have this number increase by one everytime an entry is made.
I was hoping I could use default value but I cannot seem to get it to work.
Does anyone have a simple suggestion,
Thanks in advance,
Fred
 
You can use the DefaultValue property. Use this as an example:

=DMax("[ID]","tblMyTable")+1
 
I am trying to generate a new number in a form.
I would like to have this number increase by one everytime an entry is made.
I was hoping I could use default value but I cannot seem to get it to work.
Does anyone have a simple suggestion,
Thanks in advance,
Fred

One simple way to do this is to use the Form's BeforeInsert event:

Private Sub Form_BeforeInsert()
Me!fieldname = NZ(DMax("[fieldname]", "[tablename]")) + 1
End Sub
 
Tanks to all who replied. It is appreciated!!
Regards,
Fred

John W. Vinson said:
I am trying to generate a new number in a form.
I would like to have this number increase by one everytime an entry is made.
I was hoping I could use default value but I cannot seem to get it to work.
Does anyone have a simple suggestion,
Thanks in advance,
Fred

One simple way to do this is to use the Form's BeforeInsert event:

Private Sub Form_BeforeInsert()
Me!fieldname = NZ(DMax("[fieldname]", "[tablename]")) + 1
End Sub
 
Hi, I tried that but get an error when running this. Any idea what went wrong?
Fred

John W. Vinson said:
I am trying to generate a new number in a form.
I would like to have this number increase by one everytime an entry is made.
I was hoping I could use default value but I cannot seem to get it to work.
Does anyone have a simple suggestion,
Thanks in advance,
Fred

One simple way to do this is to use the Form's BeforeInsert event:

Private Sub Form_BeforeInsert()
Me!fieldname = NZ(DMax("[fieldname]", "[tablename]")) + 1
End Sub
 
Hi, I tried that but get an error when running this. Any idea what went wrong?
Fred

Not unless you tell me what code you put in, what are your actual field and
tablenames, and the error message, no.
 
I submit to you that adding one to the value is indeed performing a math
operation upon it, so a number data type is appropriate.
 

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

Back
Top