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

BYPASS FORM_CURRENT() CODE

Status
Not open for further replies.

franksirvent

Programmer
Mar 8, 2002
358
GB
Hi

I have a lot of VB code which runs when I delete a record.
This code is found on the Form_current() event.

I take it that it runs after the record is deleted, and when it is showing the next record.

Is there a way I can avoid this from happening?
I basically don't want the code to run after a record is deleted, only just before a new record is created (the code changes the way the form looks and several other things, etc etc)

thanks in advance

 
Why not the BeforeInsert event procedure of the form ?
Or testing the Me.NewRecord property in the Current event procedure ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
thanks

i will try the me.newrecord property thingy...and see how I go.

thanks!
 
Hi Fransirvent,
Dim a string flag (variable)Call it something like "RunCurrent" and give it a value = "yes"
insert an if block in the start of the current procedure and allow the rest of the code to run only if the RunCurrent="yes"

if RunCurrent = "yes" then
<<< Put all your code here >>
Else
End If


In the delete code set the RunCurrent = "no"
then if Current procedure is running after the delete code it will find that RunCurrent doesn't equal to "yes" and will skip the code in Current!
I hope this will be of help
Take care
ANaguib
 
I would go with PHV's suggestion of moving the code to the BeforeInsert event.

I would avoid using module-level flags if possible. Often the best solution is just to move the code to where it makes the most logical sense.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top