Hey all.
I am looking for a way to save both the form and subform with the click of a single command button located on the main form.
I'm aware that the fields auto update when you go from parent to child, but that's not what I want.
For this form, it's important that the forms do not auto update when switching from parent to child, or when switching records.
One should be able to switch from parent to child form without being prompted to save (But that's not that important.) Ideally, one should only be prompted to save when they click the button.
Right now, I have the following code for the main form. It seems to do what I want, but it only applies to the main form. I'm aware I can use the same code for the subform, but I don't want to have to click on save twice.
I looked up some old threads, but I didn't find anything that worked for me.
Any suggestions?
-J. "Jon" Rogue
I am looking for a way to save both the form and subform with the click of a single command button located on the main form.
I'm aware that the fields auto update when you go from parent to child, but that's not what I want.
For this form, it's important that the forms do not auto update when switching from parent to child, or when switching records.
One should be able to switch from parent to child form without being prompted to save (But that's not that important.) Ideally, one should only be prompted to save when they click the button.
Right now, I have the following code for the main form. It seems to do what I want, but it only applies to the main form. I'm aware I can use the same code for the subform, but I don't want to have to click on save twice.
Code:
Private Sub Form_BeforeUpdate (Cancel as Integer)
Dim strMsg As String
Dim iResponse as Integer
' This is the message that will display afor the command prompt:
strMsg = "Do you wish to save your chagnes?" &Chr (10)
strMsg = "Click Yes to Save, or No to discard changes."
'Displays the message box:
iResponse = MsgBox (strMsg, vbQuestion + vbYesNo, "Save Record?"
' Check response:
If iResponse = vbNo Then
' Undo the change
DoCmd.RunCommand acCmdUndo
' Cancel the Update:
Cancel = True
End If
End Sub
I looked up some old threads, but I didn't find anything that worked for me.
Any suggestions?
-J. "Jon" Rogue