View Full Version : Determine If Changes Made to DataSheet


crhodus
03-06-2008, 07:17 AM
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

KenHigg
03-06-2008, 07:40 AM
Maybe you can check the status of the record with the form 'Dirty' property?

crhodus
03-06-2008, 08:05 AM
Thanks! It looks like that's what I needed to check.

KenHigg
03-06-2008, 08:07 AM
.
.
.
.
Cool...