J
James
It sets the focus back on the control, but then if you hit the next record
button it moves to the next record and saves the form. (not in that order of
course.) On the dropdown menu control (CarrierID) it gives me the error
message about how the table requires this. (I have made it required in the
table) I want it to just show the msgbox only not the error msg. Am I going
about this situation in the right way, and what should I do?
-----start code-------
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo Err_BeforeUpdate
If IsNull(Me.Service) Then
MsgBox "You must enter a service before saving."
Me.Service.SetFocus
Exit Sub
End If
If IsNull(Me.CarrierID) Then
MsgBox "You must select a carrier from the list before saving."
Me.CarrierID.SetFocus
Exit Sub
End If
If Not Me.NewRecord Then
If MsgBox("Are you sure you want to save these changes?", vbYesNo,
"Confirm Changes") = vbNo Then
Cancel = True
Me.Undo
End If
End If
Exit_BeforeUpdate:
Exit Sub
Err_BeforeUpdate:
MsgBox Err.Description
Resume Exit_BeforeUpdate
End Sub
Private Sub CarrierID_NotInList(NewData As String, Response As Integer)
On Error Resume Next
MsgBox "Please select from the dropdown list."
Me.CarrierID.SetFocus
Response = acDataErrContinue
End Sub
-----end code-----
button it moves to the next record and saves the form. (not in that order of
course.) On the dropdown menu control (CarrierID) it gives me the error
message about how the table requires this. (I have made it required in the
table) I want it to just show the msgbox only not the error msg. Am I going
about this situation in the right way, and what should I do?
-----start code-------
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo Err_BeforeUpdate
If IsNull(Me.Service) Then
MsgBox "You must enter a service before saving."
Me.Service.SetFocus
Exit Sub
End If
If IsNull(Me.CarrierID) Then
MsgBox "You must select a carrier from the list before saving."
Me.CarrierID.SetFocus
Exit Sub
End If
If Not Me.NewRecord Then
If MsgBox("Are you sure you want to save these changes?", vbYesNo,
"Confirm Changes") = vbNo Then
Cancel = True
Me.Undo
End If
End If
Exit_BeforeUpdate:
Exit Sub
Err_BeforeUpdate:
MsgBox Err.Description
Resume Exit_BeforeUpdate
End Sub
Private Sub CarrierID_NotInList(NewData As String, Response As Integer)
On Error Resume Next
MsgBox "Please select from the dropdown list."
Me.CarrierID.SetFocus
Response = acDataErrContinue
End Sub
-----end code-----