Suppress a form's On Current event?

fat controller

Slightly round the bend..
Local time
Today, 08:54
Joined
Apr 14, 2011
Messages
758
I have a form which has an On Current event which basically sets various items visible (or not) depending on the values of some of the fields. Previously, this was taken care of by the On Open event, but I needed it to refresh after data changed in a pop-up sub-form (see this thread

Now, that all works just fine, however the delete record button no longer works. Stepping into the code, it appears that the On Current event is stopping the record from being deleted.

Is there any way to either suppress the On Current event when the delete button is clicked, or close the form after capturing the record ID and then delete the record at table level before re-opening the form again?
 
Check out the Form.OnCurrent property, which tells the form what to do when the Current event is raised. When set to "[Event Procedure]" the Form.Current event will be handled by a Sub Form_Current(). To disable this behaviour programmatically, modify the OnCurrent property, like. . .

Code:
   Me.OnCurrent = ""  [COLOR="Green"]                 'disable current event handling[/COLOR]
   DoSomeOperation [COLOR="Green"]                    'perform a task that may cause a currrent event[/COLOR]
   Me.OnCurrent = "[Event Procedure]" [COLOR="Green"] 're-enable current event handling[/COLOR]
You can also set the OnCurrent property to the name of function, in which case the Current event of the form would run that function, like . . .
Code:
  Me.OnCurrent = "=MsgBox('Current Event')"
. . . so in this way you can programmatically alter, at runtime, how objects handle events.
 
Thanks

The OnCurrent event is Me.ResetForm which refers to a Sub that carries out the required processes.

Your solution works perfectly, thank you once again :)
 

Users who are viewing this thread

Back
Top Bottom