views:

180

answers:

1

I have a form with two subforms (on separate tab pages). It's an MDB project in Access 2003.

When it initially opens, Form_Current on the active subform fires once, as it should.

But when you move to another record (ie. from the main form), it fires Form_Current on the active subform 4 times. Then subsequent record-moves result in Form_Current firing 2 times. This is a pain, because the subforms have a lot of fields that get moved and/or hidden and so it jumps around for every Form_Current, not to mention being slow.

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

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

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

So it seems like something in Form_Current is triggering another Form_Current event. But only on the first record move.

The code in Form_Current is somewhat complex, involving custom classes and event callbacks, but generally does not touch the table data. The only thing I can think might be triggering a Form_Current is that it checks OldValue on form controls - could this be causing it?

Or anything else come to mind?

Thanks.

Eric

A: 

As TheAceMan1 once noted, "The only thing you have to watch out for with the On Current event is recursion! That is ... code in the event that causes the event to retrigger. Like moving to another record within the code. Other than that ... the event can be as hefty as required." I have found Current to be horribly twitchy. That said, it is sometimes the only place to put your code.

You may be aware that events for sub-forms trigger before those for the parent form. This is certainly true for Load, and maybe for Current as well.

I can only suggest step-by-step trouble-shooting; comment out parts, check functioning, and work it out. Of course you can always post a heap more code for us to see.

Smandoli
Thanks - it may be related to subform current triggering before parent form, then again on setting focus to subform, or something. Wish I had the time to track it down. For the moment I think the users can manage with editing one record at a time.
Eric G