S
Susan L
Thanks to John Vinson's advice, I've now successfully implemented validation
of a number of controls on a form, but now I have a different problem. I
have put a Save button on the form that commits the record to the database.
If I leave a field empty, I get the correct message about filling the field.
After clicking OK to that, however, I now get a message that the DoMenuItem
(acSaveRecord) was cancelled. Is there a way to suppress that message? The
code for the button is below. I'm not sure how to re-write the error. Also,
here's a sample of the validation for one control:
If Me!cboState & "" = "" Then
MsgBox "Please select a location."
Me![cboState].SetFocus
Cancel = True
End If
And here's the code for the button.
Private Sub cmdSave_Click()
On Error GoTo Err_cmdSave_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Exit_cmdSave_Click:
Exit Sub
Err_cmdSave_Click:
MsgBox Err.Description
Resume Exit_cmdSave_Click
End Sub
Your help will surely be appreciated.
of a number of controls on a form, but now I have a different problem. I
have put a Save button on the form that commits the record to the database.
If I leave a field empty, I get the correct message about filling the field.
After clicking OK to that, however, I now get a message that the DoMenuItem
(acSaveRecord) was cancelled. Is there a way to suppress that message? The
code for the button is below. I'm not sure how to re-write the error. Also,
here's a sample of the validation for one control:
If Me!cboState & "" = "" Then
MsgBox "Please select a location."
Me![cboState].SetFocus
Cancel = True
End If
And here's the code for the button.
Private Sub cmdSave_Click()
On Error GoTo Err_cmdSave_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Exit_cmdSave_Click:
Exit Sub
Err_cmdSave_Click:
MsgBox Err.Description
Resume Exit_cmdSave_Click
End Sub
Your help will surely be appreciated.