L
Larry06Green
I found this function code in a response from Arvin Meyer. As suggested, I
created the table called tblNextNumber and the text field called JobNumber. I
created the module called GetNextJobNumber (see below). How do I get this
calculated ID value into my new record form?
Option Compare Database
Public Function GetNextJobNumber() As Long
On Error GoTo Error_Handler
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strSQL As String
strSQL = "Select JobNumber From tblNextNumber"
Set db = CurrentDb
Set rst = db.OpenRecordset(strSQL, dbOpenDynaset)
With rst
GetNextJobNumber = !JobNumber
GetNextJobNumber = "MK-" & Format(GetNextJobNumber, "00000")
..Edit
!JobNumber = !JobNumber + 1
..Update
End With
Exit_Here:
rst.Close
Set rst = Nothing
Set db = Nothing
Exit Function
Error_Handler:
MsgBox Err.Number & ": " & Err.Description
Resume Exit_Here
End Function
created the table called tblNextNumber and the text field called JobNumber. I
created the module called GetNextJobNumber (see below). How do I get this
calculated ID value into my new record form?
Option Compare Database
Public Function GetNextJobNumber() As Long
On Error GoTo Error_Handler
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strSQL As String
strSQL = "Select JobNumber From tblNextNumber"
Set db = CurrentDb
Set rst = db.OpenRecordset(strSQL, dbOpenDynaset)
With rst
GetNextJobNumber = !JobNumber
GetNextJobNumber = "MK-" & Format(GetNextJobNumber, "00000")
..Edit
!JobNumber = !JobNumber + 1
..Update
End With
Exit_Here:
rst.Close
Set rst = Nothing
Set db = Nothing
Exit Function
Error_Handler:
MsgBox Err.Number & ": " & Err.Description
Resume Exit_Here
End Function