I have added a SubForm to my main form. The SubForm view has been set to DataSheet. I have modified the SubForm so that the AllowAdditions and DataEntry have been set to False. On my main form, I have added an "Add/Edit" button, a "Save Record" button, and a "Cancel" button.
When the "Add/Edit" button is clicked, the AllowAdditions and DataEntry property of the SubFom are set to True.
Here is my problem. The user clicks on "Add/Edit" button then decides that they do not want to add or edit a record. The user then click on the "Cancel" button.
Here is the code behind the "Cancel" button:
'--------
Private Sub btnCancelCE_Click()
Dim Msg, Style, Title
Msg = "Are you sure you DO NOT want to save your changes? Any changes made will be lost." ' Define message.
Style = vbYesNo + vbCritical + vbDefaultButton2 ' Define buttons.
Title = "Do Not Save?" ' Define title.
If MsgBox(Msg, Style, Title) = vbYes Then
ResetButtonsAndSubForm
End If
End Sub
'--------
Obviously the Message Box will be launched. What can I add/change to my code that will prevent the MsgBox from being launched if no edits or new records have occurred in the SubForm?
Thanks,
Crhodus
When the "Add/Edit" button is clicked, the AllowAdditions and DataEntry property of the SubFom are set to True.
Here is my problem. The user clicks on "Add/Edit" button then decides that they do not want to add or edit a record. The user then click on the "Cancel" button.
Here is the code behind the "Cancel" button:
'--------
Private Sub btnCancelCE_Click()
Dim Msg, Style, Title
Msg = "Are you sure you DO NOT want to save your changes? Any changes made will be lost." ' Define message.
Style = vbYesNo + vbCritical + vbDefaultButton2 ' Define buttons.
Title = "Do Not Save?" ' Define title.
If MsgBox(Msg, Style, Title) = vbYes Then
ResetButtonsAndSubForm
End If
End Sub
'--------
Obviously the Message Box will be launched. What can I add/change to my code that will prevent the MsgBox from being launched if no edits or new records have occurred in the SubForm?
Thanks,
Crhodus