P
pushrodengine via AccessMonster.com
I’m using coding below to insert “0000-yy†into a textbox.
The numbering system works great except that I have lost the ability to move
back to the previous record. It must be something to do with the code.
How can I fix it?
Private Sub Form_Current()
If Me.NewRecord Then
Dim strWhere As String
Dim varResult As Variant
strWhere = "IncidentID Like """ & Format(Date, "yy") & "*"""
varResult = DMax("IncidentID", "tblIncidentLog", strWhere)
If IsNull(varResult) Then
Me.IncidentID = Format(Date, "yy") & "-0001"
Else
Me.IncidentID = Left(varResult, 3) & _
Format(Val(right(varResult, 4)) + 1, "0000")
End If
End If
End Sub
The numbering system works great except that I have lost the ability to move
back to the previous record. It must be something to do with the code.
How can I fix it?
Private Sub Form_Current()
If Me.NewRecord Then
Dim strWhere As String
Dim varResult As Variant
strWhere = "IncidentID Like """ & Format(Date, "yy") & "*"""
varResult = DMax("IncidentID", "tblIncidentLog", strWhere)
If IsNull(varResult) Then
Me.IncidentID = Format(Date, "yy") & "-0001"
Else
Me.IncidentID = Left(varResult, 3) & _
Format(Val(right(varResult, 4)) + 1, "0000")
End If
End If
End Sub