autonumber - function

  • Thread starter Thread starter learning_codes
  • Start date Start date
L

learning_codes

Hi,

I will like the function. Is there a way to make it a default as 0 in
the table: tblHighNum.


Public Function isIncrement(ByVal var As Variant) As Long
Dim lng as Long

lng = DLookup("Num", "tblHighNum") + 1
CurrentDb.Execute "UPDATE tblHighNum SET Num = " _
& lng
isIncrement = lng

End Function

Your help would be much appreciated.

Thanks.
 
Hi,

I will like the function. Is there a way to make it a default as 0 in
the table: tblHighNum.


Public Function isIncrement(ByVal var As Variant) As Long
Dim lng as Long

lng = DLookup("Num", "tblHighNum") + 1
CurrentDb.Execute "UPDATE tblHighNum SET Num = " _
& lng
isIncrement = lng

End Function

Your help would be much appreciated.

Thanks.

If your database has multiple users, this approach is a mistake. There is
definitely the potential that two or more users could get the same Ing
number by using this function.

Jet already has an autonumber data type: why try and reinvent the wheel?
 
Back
Top