cancel updates on both the main &subform

Sudha

Registered User.
Local time
Today, 17:25
Joined
May 1, 2001
Messages
29
hi,

how can i cancel an update on both the main form and subform? I have a cancel button on my main form. using this how can i cancel the updates on both the forms? if i give cancel = true, with msgbox, in the before update of the main form only the mainform's changes gets cancelled.if i give it both on the main and subform, it msgbox asks twice if the changes should be cancelled

sudha
sudha
 
This is a guess.

Try doing an explicit DoCmd.UNDO of the sub-form in the routine doing the CANCEL of the main form.

However, it is possible that if your referential integrity is set incorrectly, you might not get this to work so easily.
 
Sudha,

Did you find out eventually how to do it as I also have the same dilemma. How can cancel update work both on main form and subform??

Thanks.
 
I had the same problem. Thsi is how io solved it.
First add a cancel button to the main srceen then add and unbound field call Dontsave to your form. (You can make this field invisible. In the Cancel event Then create an event that set the field equal to 1 This is trhe code behind my button:

On Error GoTo Err_Command17_Click

Me!Dontsave = 1
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
DoCmd.Close
Exit_Command17_Click:
Exit Sub

Err_Command17_Click:

Resume Exit_Command17_Click

Then in the before update of the subform:
If Forms!form1!Dontsave = 1 Then

DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
End If
Forms!form1!Dontsave = 0

This closes the form to update the screen. You can reopen it in the same place by adding the open statement to the before update event. Before you close the form ave your id or what ever you need to open in the same place.

I hope this helps.

Maria
 

Users who are viewing this thread

Back
Top Bottom