Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

BeforeUpdate vs OnClick

Status
Not open for further replies.

rafe

Technical User
Aug 18, 2000
194
0
0
US
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 [sig][/sig]
 
Try setting the CancelFlag in the MouseMove event. You will need to set it to false in the MouseMove event of the section of the form that holds the cancel button (i.e. Detail, Header or Footer - NOT the Form_MouseMove).

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.

[sig]<p>Keith C Taylor<br><a href=mailto:TekTips@kctaylor.co.uk>TekTips@kctaylor.co.uk</a><br><a href= Information Gardener</a><br>The C stands for Computer![/sig]
 
Thank you Keith!

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()
[tab]If Nz(Me.Wage, 0) = 0 Then
[tab][tab]Me.AllowAdditions = False
[tab][tab]Me.Wage.SetFocus
[tab][tab]Exit Sub
[tab]End If
[tab]'many more validatioins in here.....
End Sub

My solution is bat-faced ugly, but it works for now.

rafe [sig][/sig]
 
Talk about brain fried!

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. [sig][/sig]
 
rafe, I have a question. What will you do if the user has added say three line items to the subform and then decides to bail out and pretend the thing never happened? Are you able to somehow cause all three line items to go away also?
[sig]<p>John A. Gilman<br><a href=mailto:gms@uslink.net>gms@uslink.net</a><br>[/sig]
 
John,

i'm causing the records to never be added to the &quot;real&quot; 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 (&quot;Form/Subform Design Question&quot;). 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 &quot;real&quot; 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 &quot;Easy question: DoCmd.GotoRecord in Subform&quot;)

thanks

rafe [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top