Need help with expression for Table

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to have Access add the next number in a sequence to the Next Record
automatically. My format is D-2467 and I want Access to add the next number
which is D-2468? Can anyone help me do this? Thanks. Your help is
appreciated.
 
I want to have Access add the next number in a sequence to the Next Record
automatically. My format is D-2467 and I want Access to add the next number
which is D-2468? Can anyone help me do this? Thanks. Your help is
appreciated.

You cannot do this in a Table; tables have no usable events.

If the value always starts with D- then there's no benefit in storing
the prefix - just use a Long Integer and set the field's Format to

"D-"0000

If you use (as you should!) a Form to do your data entry, you can use
code in the Form's BeforeInsert event:

Private Sub Form_BeforeInsert(Cancel as Integer)
Me!txtID = NZ(DMax("[ID]", "[yourtable]")) + 1
End Sub


John W. Vinson[MVP]
 
Back
Top