469,592 Members | 1,799 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,592 developers. It's quick & easy.

Speed tip: Set RowSource of Subform's Combo box in GotFocus event rather than Enter

Hello all,

I just discovered something (stop me if you've heard this before....) that
was causing me a significant performance hit when opening a form with

To speed up loading the form, I set the rowsources of its, and its
subforms', combo boxes in the "Enter" events of the combo boxes. That's the
standard trick for not loading the rowsource unless/until the user actually
needs the combo box. For example:

If Me!cboInitial.RowSource = "" Then _
Me!cboInitial.RowSource = Me!txtPrefix & "refCarInitials" ... or
some query

I also set the subforms' SourceObjects, LinkChildFields, and RecordSource in
the Load event of the main form.

What I discovered is that setting the SourceObject, etc fires off the Enter
event of the combo boxes in the subforms. In fact, even if you don't set
these properties in the code, but instead have them predefined, Access will
"Enter" the combo boxes of the subforms when opening up the main form. So
the RowSources of those combo boxes get run way before the user has a chance
to click on them. This defeats the aim of speeding up form loading by
avoiding filling those RowSources until needed.

The solution was simple enough - move the RowSource code to the GotFocus
event of the combo boxes, which does not get fired by the main form opening.

Note that for combo boxes on the main form, it doesn't matter, as they
aren't "entered" when the main form is opened. It's the main form's act of
"setting up" its subforms that causes Access to enter the subforms' combo
boxes. You can test this be putting breakpoints or messageboxes in the
"Enter" events of the combo boxes.

Thought this might help someone. BTW, I got the inspiration for the
solution from an old post I read from someone (was it David Fenton?) who
said he couldn't remember why he always put the RowSource code in the
GotFocus event rather than the Enter event. Maybe this was why?


Nov 12 '05 #1
0 3121

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

14 posts views Thread by Steve Jorgensen | last post: by
8 posts views Thread by bbdata | last post: by
6 posts views Thread by lauren quantrell | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.