I am using the following code to prompt the use when a new record is added.
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo Form_BeforeUpdate_error
Dim intResponse As Integer
Dim strMsg As String
strMsg = "You have made changes that will add a new record. Do you want to save changes?"
intResponse = MsgBox(strMsg, vbQuestion + vbYesNo, "Confirm Adding record")
Select Case intResponse
Case vbNo
Cancel = True
End Select
Form_BeforeUpdate_exit:
Exit Sub
Form_BeforeUpdate_error:
MsgBox Err & vbCr & Err.Description, vbExclamation, "Form_BeforeUpdate"
Resume Form_BeforeUpdate_exit
End Sub
If the user accidentally clicks the cmd button to add a new record, an “add a record” form opens and when the user closes the form (without updating any data because the form was accidentally opened) , a yes no msgbox appears. When no is selected, the user is faced with the following message on “You can’t save this record at this time.
Database may have encountered an error while trying to save a record. If you close this object now, the data changes you make will be lost. Do you want to close the database object anyway?” I am not sure why the message is generated, but a assume it is because the new record is blank since no data has been entered.
This actually works if yes is clicked, but my users will get confused by this message and probably will not know what to do. My question is why is this message generated when the user does not want to save changes, and can I just make a yes no msgbox that says “are you sure you want to close the form and abandon any changes”.
Also,
If a user adds or changes data on the enter new record form, then clicks no when prompted to save changes, the following message is received:
“The DoMenuItem action was canceled.
You used a method of the DoCmd object to carry out an action in Visual Basic, but then clicked the Cancel in a dialog box. For example you used the Close method to close a changed from, then clicked Cancel in the dialog box that asks if you want to save the changes you made on the form.”
Is there any way for this msgbox not to show up If the user cancels their changes? Or maybe a less ominous msg that says “You canceled the changes”.
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo Form_BeforeUpdate_error
Dim intResponse As Integer
Dim strMsg As String
strMsg = "You have made changes that will add a new record. Do you want to save changes?"
intResponse = MsgBox(strMsg, vbQuestion + vbYesNo, "Confirm Adding record")
Select Case intResponse
Case vbNo
Cancel = True
End Select
Form_BeforeUpdate_exit:
Exit Sub
Form_BeforeUpdate_error:
MsgBox Err & vbCr & Err.Description, vbExclamation, "Form_BeforeUpdate"
Resume Form_BeforeUpdate_exit
End Sub
If the user accidentally clicks the cmd button to add a new record, an “add a record” form opens and when the user closes the form (without updating any data because the form was accidentally opened) , a yes no msgbox appears. When no is selected, the user is faced with the following message on “You can’t save this record at this time.
Database may have encountered an error while trying to save a record. If you close this object now, the data changes you make will be lost. Do you want to close the database object anyway?” I am not sure why the message is generated, but a assume it is because the new record is blank since no data has been entered.
This actually works if yes is clicked, but my users will get confused by this message and probably will not know what to do. My question is why is this message generated when the user does not want to save changes, and can I just make a yes no msgbox that says “are you sure you want to close the form and abandon any changes”.
Also,
If a user adds or changes data on the enter new record form, then clicks no when prompted to save changes, the following message is received:
“The DoMenuItem action was canceled.
You used a method of the DoCmd object to carry out an action in Visual Basic, but then clicked the Cancel in a dialog box. For example you used the Close method to close a changed from, then clicked Cancel in the dialog box that asks if you want to save the changes you made on the form.”
Is there any way for this msgbox not to show up If the user cancels their changes? Or maybe a less ominous msg that says “You canceled the changes”.