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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

BeforeUpdate Event Question!!!!!

Status
Not open for further replies.

legs00

Programmer
Oct 17, 2001
36
0
0
CA
Hi,
I have a form where the user can choose an activity they would like to modify, which opens a MODACT form. In this form the user can make any modifications and cancel at any time.

My problem is that my code has a Form_BeforeUpdate() event and if the cancel button is clicked the beforeupdate event will be called before the form will unload.

The BeforeUpdate Event should only be used if the user presses the Modify button. Is there a way to to call Form_BeforeUpdate Event from cmdModify_Click???

Thanks,
Legs
 
Hi Legs!

One possibility is to add a form level boolean varible to allow the code in the Before_Update event to run only when you want it too.

Private bolRunCode As Boolean

in the Form_Current event set bolRunCode = True. In the Form_BeforeUpdate event use:

If bolRunCode = True Then
run your code
Else
Me.Undo
Cancel = -1
End If

In the Click event of the cancel button set bolRunCode to False.

hth
Jeff Bridgham
bridgham@purdue.edu
 
Hi Jebry,

Well thank you!! I put my boolean variable private in my general and did the rest as you suggested and everything works fine!!!!

s-)%-)*:->*
Legs
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top