How To Number Consecutively Without Using AutoNumber?

  • Thread starter Thread starter Katlyn
  • Start date Start date
K

Katlyn

Does anyone know how to add consequitive numbering to a
table through a form without using the AutoNumber feature?
VB code that will do it?
Trouble is that when someone changes their mind, the
numbering keeps going as if the one not saved is in use.
 
You can use Dmax function to get the largest number then add one to that.
Here is a sample

Public Function getNextNumber() As Long
Dim dbs As Database
Dim rst As Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("SELECT Max(tblNumber.Number) AS maxNumber
FROM tblNumber")
getNextNumber = rst!maxNumber + 1
End Function
 
Back
Top