Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
' Usage codes (keys for the LastKey table)
Public Const gnkWorkOrder = 1 ' work order numbers
' Public Const gnkXxxxNumber = 2 ' may add more in future
Public Function GetNextKey(Usage As Long) As Long
Const SQL = "SELECT LastKey FROM LastKeys " _
& "WHERE Usage="
Dim db As DAO.Database, rst As DAO.RecordSet
Set db = CurrentDb()
Set rst = db.OpenRecordset(SQL & Usage, _
dbOpenDynaset, dbDenyRead, dbPessimistic)
If rst.EOF Then
' Handle error: Invalid Usage argument
Else
db.Workspaces(0).BeginTrans
On Error GoTo GNK_Error
rst.Edit
GetNextKey = rst!LastKey + 1
rst!LastKey = nextKey
rst.Update
db.Workspaces(0).CommitTrans
End If
rst.Close
GNK_Exit:
Set rst = Nothing
Set db = Nothing
Exit Function
GNK_Error:
Select Case Err.Number
Case 3260, 3262 ' lock conflict:
DoEvents ' let the system run a moment
Resume ' try again
Case Else
Err.Raise Err.Number
End Select
End Function