BeforeUpdate vs OnClick
BeforeUpdate vs OnClick
(OP)
Hi all,
I have a form with a continuous subform for line item entry. I check data input in the Form_BeforeUpdate event. Now, I wanted to have a bailout button on the main form that would cancel processing & clear the form & subform. So I ....
1) Created a module with a global boolean variable that I could set in the main form's "Cancel Button"'s OnClick event. Called CCFglobals.CancelFlag
2) Then I check the global flag in the subform's BeforeUpdate.
OK, this is a mess because the subform's BeforeUpdate happens before the main form's button OnClick. I checked this with stop points in both event subroutines.
Any idea would be appreciated.
Thanks
rafe
I have a form with a continuous subform for line item entry. I check data input in the Form_BeforeUpdate event. Now, I wanted to have a bailout button on the main form that would cancel processing & clear the form & subform. So I ....
1) Created a module with a global boolean variable that I could set in the main form's "Cancel Button"'s OnClick event. Called CCFglobals.CancelFlag
2) Then I check the global flag in the subform's BeforeUpdate.
OK, this is a mess because the subform's BeforeUpdate happens before the main form's button OnClick. I checked this with stop points in both event subroutines.
Any idea would be appreciated.
Thanks
rafe
RE: BeforeUpdate vs OnClick
In theory this could fail if the user has the mouse over the cancel button whilst manipulating the data with the keyboard. I can only suggest setting a warning label visible or not as you change your CancelFlag value.
Keith C Taylor
TekTips@kctaylor.co.uk
The Information Gardener
The C stands for Computer!
RE: BeforeUpdate vs OnClick
However I got your solution a bit too late. What I wound up doing was putting the field validations in the (sub)Form_AfterUpdate event & then disabling the subform's ablity to add new records upon validation failure. I have to re-enable the subform's ablity to add records in the main form at times (upon starting or restarting the entry process), so be careful if you try it.
Private Sub Form_AfterUpdate()
If Nz(Me.Wage, 0) = 0 Then
Me.AllowAdditions = False
Me.Wage.SetFocus
Exit Sub
End If
'many more validatioins in here.....
End Sub
My solution is bat-faced ugly, but it works for now.
rafe
RE: BeforeUpdate vs OnClick
I've put the between field validations in an AcceptButton_OnClick event.
Pro: No stupid enabling/disabling of buttons & record additions.
Con: Within record validations only happen at the end of all input. Not tragic tho.
RE: BeforeUpdate vs OnClick
John A. Gilman
gms@uslink.net
RE: BeforeUpdate vs OnClick
i'm causing the records to never be added to the "real" file.
i've been going thru the design newbie development process in the techTips forums. your help (as well as other folks) has really sped me thru this open development process. THANK YOU!
i asked the design question in a previous post ("Form/Subform Design Question"). i'm using a buffer file to enter line items & then upon the acceptButton_OnClick i'm validating & then if it passes i'm moving info to the "real" file. if it fails validation i'm going back to the record & field of the item that failed (yet another post where i'm takling to myself "Easy question: DoCmd.GotoRecord in Subform")
thanks
rafe