P
pushrodengine via AccessMonster.com
Part of the code below brings up a message box letting the user know that
they must press Add Incident button to save the incident.
The problem I’m having is when the Cancel button is pressed it behaves the
same way the OK button. The OK button works properly. I would like the Cancel
to return user to the form so that information may be re-entered.
How do I modify the code to make that possible?
_____________________________________________________________________
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.NewRecord Then
Dim strWhere As String
Dim varResult As Variant
Dim iAns As Integer
If Me!chkOKToClose = False Then
iAns = MsgBox("Please use the Add Incident Button to Save the
Incident" & " or Select Cancel to Re-enter Incident Log", vbOKCancel, "Re-
enter Incident Log")
Cancel = True
If iAns = vbCancel Then
Me.Undo
End If
End If
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
_____________________________________________________________________
Thanks
they must press Add Incident button to save the incident.
The problem I’m having is when the Cancel button is pressed it behaves the
same way the OK button. The OK button works properly. I would like the Cancel
to return user to the form so that information may be re-entered.
How do I modify the code to make that possible?
_____________________________________________________________________
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.NewRecord Then
Dim strWhere As String
Dim varResult As Variant
Dim iAns As Integer
If Me!chkOKToClose = False Then
iAns = MsgBox("Please use the Add Incident Button to Save the
Incident" & " or Select Cancel to Re-enter Incident Log", vbOKCancel, "Re-
enter Incident Log")
Cancel = True
If iAns = vbCancel Then
Me.Undo
End If
End If
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
_____________________________________________________________________
Thanks