MS Access form_current () fires multiple times

I have a form with two subforms (on separate tabs). This is an MDB project in Access 2003.

When it initially opens, the Form_Current in the active subordination is fired once, as it should.

But when you navigate to another record (i.e. from the main form), it fires Form_Current in the active subformat 4 times. Then subsequent writes cause Form_Current to fire 2 times. This is a pain because subforms have a lot of fields that move and / or hide, and so they jump every Form_Current, let alone be slow.

I am opening a form with a filter via DoCmd.OpenForm (it actually sends the filter via OpenArgs). FilterOn is set only once, in Form_Open on the main form, never in subforms. Form_Current is not explicitly called anywhere else in the code.

When I look at the call stack when Form_Current fires for the first time, it looks like this:

my_subform.Form_Current
[<Debug Window>]
my_subform.Form_Current

      

So it looks like something in Form_Current is triggering another Form_Current Event. But only at the first movement of the record.

The code in Form_Current is somewhat complex, including custom classes and events, but usually not dealing with table data. The only thing I can think of is that the launch of the Form_Current package is that it checks the OldValue on the control forms - could this be the reason?

Or does anything else come to mind?

Thanks.

Eric

+2


a source to share


1 answer


As TheAceMan1 noted, "The only thing you need to watch for the On Current event is the recursion! This is ... the code in case the event is overwritten. Like jumping to another entry in the code Other than that ... the event can be just as heavy as required. " I found Tok twitch terribly. However, this is sometimes the only place to put your code.

You may be aware that events for subforms are fired earlier than for the parent form. This is certainly true for Load and possibly Current.



I can only suggest a step by step problem; comment on details, check functioning and work through. Of course, you can always post a bunch of more code for us.

+1


a source







All Articles