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

OnCurrent Event Firing Twice on Subform

Status
Not open for further replies.

dftjsn

Programmer
Feb 25, 2002
43
US
My application starts with a Main Switchboard. Clicking a command button opens a form with a tab control. The second tab of the tab control contains a subform with an image control on it. My problem is that the OnCurrent event of this subform runs twice whenever the user moves between records on the first (main) tab (using PgUp/PgDn or the navigation buttons) of the tab control. Because some of the images being displayed in the image control are large, it takes time (and the importing graphic progress bar automatically pops up). Interestingly, OnCurrent doesn't run twice when the user first moves to the tab control form from the Main Switchboard.

I've stepped through the code to try to see what triggers the second OnCurrent event, but to no avail. Execution reaches the Exit Sub command on the first pass and then goes right back to the top of the Sub for a second pass. I've tried commenting out everything in the OnCurrent event and it still runs through it twice so nothing in the OnCurrent event would appear to be triggering itself.

If I run the tab control form by itself (not from the Main Switchboard), the OnCurrent event of the subform works fine (i.e. runs once). I have a second tab control form with a subform that is invoked from the Main Switchboard. It too runs the OnCurrent event twice, but it isn't a big issue as it runs so quickly without any messages.

Does anyone have any ideas why the OnCurrent event would run twice in this situation and how to prevent it?

Thanks!

dftjsn [bigsmile]
 
df: Load up your subform SourceControl after the "tab" is selected; i.e., on the "OnChange" event of the page control.
 
Isadore,

Thanks. I think I follow what you say ... assign the subform recordsource when the user clicks the tab to move to the subform. Unfortunately, the OnCurrent event still fires for the subform when then main (tabcontrol) form is loaded. I get error messages because the OnCurrent event expects to load some data even if the user has entered the subform tab yet.

dftjsn
 
Try changing the sub to a function, i.e. just change the decalartion of the sub. You don't have to return anything.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top