LarryDeLaruelle
Technical User
The main form contains two sub forms on a tab control. When the cursor moves to one of the subforms, the record is committed.
I have an undo button on the form that tests the dirty property of the form: if true, the undo action is run, if false, the delete action is run. The undo button is not enabled until some information is entered into the First Name field. Here is the code:
If Dirty Then
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
Else
DoCmd.SetWarnings False
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
DoCmd.SetWarnings True
End If
This works fine if the user clicks undo immediately after adding data to a subform without making any other changes to the main form.
My problem is when data are added to the subforms and then the user updates another value on the main form. The dirty property is then true and only the undo action is triggered; the main record and any subform records are still there.
Is there a way to test whether the record has been saved and then run the delete action? I've considered capturing the record id and using a dlookup prior to running the undo/delete code but, I guess, I am looking for something more elegant.
Thanks.
Larry De Laruelle
ldelaruelle@familychildrenscenter.org
I have an undo button on the form that tests the dirty property of the form: if true, the undo action is run, if false, the delete action is run. The undo button is not enabled until some information is entered into the First Name field. Here is the code:
If Dirty Then
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
Else
DoCmd.SetWarnings False
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
DoCmd.SetWarnings True
End If
This works fine if the user clicks undo immediately after adding data to a subform without making any other changes to the main form.
My problem is when data are added to the subforms and then the user updates another value on the main form. The dirty property is then true and only the undo action is triggered; the main record and any subform records are still there.
Is there a way to test whether the record has been saved and then run the delete action? I've considered capturing the record id and using a dlookup prior to running the undo/delete code but, I guess, I am looking for something more elegant.
Thanks.
Larry De Laruelle
ldelaruelle@familychildrenscenter.org