Need help with expression for Table

  • Thread starter Product Development Admin
  • Start date
P

Product Development Admin

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.
 
J

John Vinson

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]
 

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