I am developing a contract management database. Each new
contract will be assigned the next sequential number. I
want to have a base info entry screen. Is there a way to
pre-load the next number in the sequence; either in an
entry box, or as a number displayed on the form?
thanx
jf
You'll need a little bit of VBA code. Exactly how the code works
depends on the circumstances: if it's a one-user database, or if it's
very unlikely that you'll have two users trying to assign a number
simultaneously, you can use code in the Form's BeforeInsert event
like:
Private Sub Form_BeforeInsert(Cancel as Integer)
Me!txtContractNo = NZ(DMax("[ContractNo]", "Contracts")) + 1
End Sub
This runs a slight risk of two users getting the same Max if one of
them opens a new record while another user has a new record open (but
unsaved). If you want to avoid this, you can use a table holding the
next number - Getz et al. have some robust code for the purpose in
their _Developer's Handbook_ and there are other examples on the web.
Search for "Access Custom Counter".