G
Gezza Collins
Hi,
I have a bound form with a subform containing a datasheet. I want to
implement a cancel or comit buttons on the form, is there any sure fire way
of doing this on a bound form.
I've been down the route of using undo on the beforeupdate events of both
forms but you've always got the problem of multiple changes on the main form
and multiple changes on the sub form saving records automatically and
therefore not undoing all changes.
I'm leaning more towards creating unbound forms and writing the records on
the commit using recordsets but for piece of mind I'd like to know if there
is any way this can be done on a bound form and subform.
Example code:
Module Level:
--------------
Public gblCancel as Boolean
On Main Form:
---------------
Private Sub Form_Load()
gblCancel = False
End Sub
Private Sub cmdCancel_Click()
gblCancel = True
DoCmd.Close acForm, "tblInitMaster"
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
If gblCancel = True Then Me.Undo
End Sub
On Subform
-------------
Private Sub Form_BeforeUpdate(Cancel As Integer)
If gblCancel = True Then Me.Undo
End Sub
I have a bound form with a subform containing a datasheet. I want to
implement a cancel or comit buttons on the form, is there any sure fire way
of doing this on a bound form.
I've been down the route of using undo on the beforeupdate events of both
forms but you've always got the problem of multiple changes on the main form
and multiple changes on the sub form saving records automatically and
therefore not undoing all changes.
I'm leaning more towards creating unbound forms and writing the records on
the commit using recordsets but for piece of mind I'd like to know if there
is any way this can be done on a bound form and subform.
Example code:
Module Level:
--------------
Public gblCancel as Boolean
On Main Form:
---------------
Private Sub Form_Load()
gblCancel = False
End Sub
Private Sub cmdCancel_Click()
gblCancel = True
DoCmd.Close acForm, "tblInitMaster"
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
If gblCancel = True Then Me.Undo
End Sub
On Subform
-------------
Private Sub Form_BeforeUpdate(Cancel As Integer)
If gblCancel = True Then Me.Undo
End Sub