Epilepsie said:
I appreciate your response Hugh, but I'm in need of using
the offset Autonumber as a receipt number on preprinted
sheets of receipt forms. If an autonumber is not the way
to go here, could you please elaborate about what the other
schemes should be...
Thanks for your time and help,
Dave H
Here is some code to do this. It works for both single and multi-user
scenarii.
You will need a new separate Table (tblSeries) having just one Field
(NextNumber) of type Long Integer to store the incrementing number.
The Table will have no index and will not be related to any other Table.
Dim rst As Recordset, db As Database
Dim lngNextNumber As Long
Set db = CurrentDb
'Open tblSeries, lock, read next number, increment, update and unlock.
Set rst = db.OpenRecordset("tblSeries", , dbDenyRead)
With rst
.MoveFirst
.Edit
lngNextNumber = ![NextNumber]
![NextNumber] = lngNextNumber + 1
.Update
End With
rst.Close
Set db = Nothing
This code is designed for Access 97. If you are using a later version,
you will need to use DAO.Recordset and DAO.Database and make sure you
have the appropriate reference set for the DAO Library.
The incrementing number is returned to you in the variable
lngNextNumber.
This code should be in the Click event of the command button you use
finally to commit your numbered record. This must happen after all
opportunities to abort your record, otherwise you could have gaps in
your numbering to explain to your auditors! After this code, you will
need to store the number value in your Table holding your records.
If, in your system, you need other unrelated number series, just add
another Field to tblSeries and manage it in a similar manner.
hth
Hugh