×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

BeforeUpdate vs OnClick

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

RE: BeforeUpdate vs OnClick

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.

Keith C Taylor
TekTips@kctaylor.co.uk
The Information Gardener
The C stands for Computer!

RE: BeforeUpdate vs OnClick

(OP)
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()
    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

(OP)
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.

RE: BeforeUpdate vs OnClick

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?

John A. Gilman
gms@uslink.net

RE: BeforeUpdate vs OnClick

(OP)
John,

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close