undo on a subform

bunji

Registered User.
Local time
Today, 22:10
Joined
Apr 26, 2005
Messages
124
I have a form with a subform, on the mainform there is an undo button but when someone makes changes on the subform the undo button wont run and the error message "The command or action Undo isn't available now". How can i get the mainform to detect that changes have been made on the subform and then if the button is clicked undo the changes.
 
Can anyone help me, i have got he subform that when dirty will load the undo button on the main form but when this is clicked, it is undo the subform as it is saying this command or action cannot be done now, presuming that it isnt picking up the changes.

Is there anyway i can say something like

If subform dirty then
Undo
Else
Nothing

I really would like to solve this problem.

Many Thanks
 
Putting the button on the subForm is the easiest way or using code and the BeforeUpdate event of the subForm to ask if users want to save or discard changes
 
Ok i put this in

Private Sub Form_BeforeUpdate(Cancel As Integer)
If MsgBox("Are you sure you make the changes to this record?", vbExclamation + vbYesNo) = vbYes Then
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Else
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
End If

End Sub

However i get the following error when clicking Yes.

Run-Time error '2115':
The macro or Function set to the beforeUpdate or ValidationRule property for this field is preventing Microsoft Access from saving the data in the field.
 
Maybe if i post the db (its in XP) someone will be able to understand my problem.

I have stripped everything out but you have the form, try updating a the air craft details.
 

Attachments

Users who are viewing this thread

Back
Top Bottom