Hi all,
I have followed the instructions in the link below to add a save button (that is grayed out until data is entered) and a notification when the form is closed without saving first. It works perfectly, but I have several forms that have subforms that it doesn't work with. The save button is on the main form and the records are on the subform. How can I tweak the code to make it work in these situations?
https://www.iaccessworld.com/create-...n-save-change/
Here is the vba code I added:
Private Sub Form_Dirty(Cancel As Integer)
Me.cmdSave.Enabled = True
End Sub
Private Sub cmdSave_Click()
Saved = True
DoCmd.RunCommand(acCmdSaveRecord)
Me.cmdSave.Enabled = False
Saved = False
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim Response As Integer
If Saved = False Then
Response = MsgBox("Do you want to save the changes on this record?", vbYesNo, "Save Changes?")
If Response = vbNo Then
Me.Undo
End If
Me.cmdSave.Enabled = False
End If
End Sub