Determine If Changes Made to DataSheet

crhodus

Registered User.
Local time
Today, 16:25
Joined
Mar 16, 2001
Messages
257
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
 
Maybe you can check the status of the record with the form 'Dirty' property?
 
Thanks! It looks like that's what I needed to check.
 

Users who are viewing this thread

Back
Top Bottom