I don't know if I am missing something simple or if I am trying to make this too simple.
I am creating a work order number from the last 2 digits of the year, which seems to be working.
The 2nd part of the work order number should increment by "1" after counting the records. The Work Order Number actally works at this point, as in 04-1, however, it always gives me a 04-1 and won't increase. Any advice will be greatly appreciated.
Private Sub Form_Current()
' Set Variables for first part of the New Work Order Number
Dim yr As Date
Dim WONumberYear As Variant
' Set up date defining the first part of the Work Order Number
yr = Date
WONumberYear = Right(yr, 2) + "-"
'Set up variables for the second part of the Work Order Number
Dim WONumber As Integer
Dim rs As DAO.Recordset
Dim db As DAO.Database
Set db = CurrentDb
Set rs = db.OpenRecordset("tblAvionicsMainWO")
rs.MoveLast
' Set up Integer for second part of Work Order Number
If rs.BOF Then
WONumber = 1
ElseIf rs.EOF Then
WONumber = rs.RecordCount
Else
WONumber = WONumber + 1
End If
' Creates New Work Order Number and puts it in the Work Order Box
Dim WO2Number As String
WO2Number = WONumber
Me.txtWO = WONumberYear + WO2Number
' Closes active Recordset
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
End Sub
Thanks in advance for the help.
Jerry
I am creating a work order number from the last 2 digits of the year, which seems to be working.
The 2nd part of the work order number should increment by "1" after counting the records. The Work Order Number actally works at this point, as in 04-1, however, it always gives me a 04-1 and won't increase. Any advice will be greatly appreciated.
Private Sub Form_Current()
' Set Variables for first part of the New Work Order Number
Dim yr As Date
Dim WONumberYear As Variant
' Set up date defining the first part of the Work Order Number
yr = Date
WONumberYear = Right(yr, 2) + "-"
'Set up variables for the second part of the Work Order Number
Dim WONumber As Integer
Dim rs As DAO.Recordset
Dim db As DAO.Database
Set db = CurrentDb
Set rs = db.OpenRecordset("tblAvionicsMainWO")
rs.MoveLast
' Set up Integer for second part of Work Order Number
If rs.BOF Then
WONumber = 1
ElseIf rs.EOF Then
WONumber = rs.RecordCount
Else
WONumber = WONumber + 1
End If
' Creates New Work Order Number and puts it in the Work Order Box
Dim WO2Number As String
WO2Number = WONumber
Me.txtWO = WONumberYear + WO2Number
' Closes active Recordset
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
End Sub
Thanks in advance for the help.
Jerry