Form takes long time to open (1 Viewer)

Gismo

Registered User.
Local time
Today, 09:42
Joined
Jun 12, 2017
Messages
1,298
Hi all,

I have a form that is not bound to any query or table
I have a combobox to search from one table
There is a subform to display records related to the combobox

The form takes very long to open
The query behind the combox does not take very long to display all of the records from the table
When a record is selected, the subform almost instantaneously displays the records

The only problem is opening up the main form

Please could you advise
 

bob fitz

AWF VIP
Local time
Today, 07:42
Joined
May 23, 2011
Messages
4,717
Don't set the Record Source of the subform until after the main form has opened.
Don't set the Control Source of any combo boxes and/or listboxes until after the main form has opened.
 

Gismo

Registered User.
Local time
Today, 09:42
Joined
Jun 12, 2017
Messages
1,298
Don't set the Record Source of the subform until after the main form has opened.
Don't set the Control Source of any combo boxes and/or listboxes until after the main form has opened.
Hi,

Please could you explain how to achieve this?
Not sure hw to set source after form has opened
 

Minty

AWF VIP
Local time
Today, 07:42
Joined
Jul 26, 2013
Messages
10,355
Do the loading of the various option in the form load event.

So set all your combo box row sources to nothing.
Then in code set them:

Me.MyCombo.Rowsource = "SELECT Field1 FROM MYTable" (Or use a query name)

Same with the Sub forms:

Me.MySubformControl.SourceObject = "sfrm_MySubform"
 

Gismo

Registered User.
Local time
Today, 09:42
Joined
Jun 12, 2017
Messages
1,298
Do the loading of the various option in the form load event.

So set all your combo box row sources to nothing.
Then in code set them:

Me.MyCombo.Rowsource = "SELECT Field1 FROM MYTable" (Or use a query name)

Same with the Sub forms:

Me.MySubformControl.SourceObject = "sfrm_MySubform"
The main form is not bound to any source

There are no events on this form

The combo box is bound directly to the Tbl, how do i set the combo box source to nothing? this is where i get the records to be shown in the subform. Maybe I am misunderstanding the statement

The subform is bound to a query

I set my subform to Link master fields and Link Child fields

Will this cause it to take longer to open the main form?
 
Last edited:

Minty

AWF VIP
Local time
Today, 07:42
Joined
Jul 26, 2013
Messages
10,355
How many records are in your combo table?
If you temporarily disable the combo's record source does your form load more quickly?

How complex is the query for the subform?
 

Gismo

Registered User.
Local time
Today, 09:42
Joined
Jun 12, 2017
Messages
1,298
How many records are in your combo table?
If you temporarily disable the combo's record source does your form load more quickly?

How complex is the query for the subform?
The combo box reads about 2700 records
The subform reads about 2000 records when not filtered and when the query runs the result is almost instantanious
So the query is very basic
 

Minty

AWF VIP
Local time
Today, 07:42
Joined
Jul 26, 2013
Messages
10,355
Okay, that shouldn't be slow, although 2700 rows in a combo is quite a lot.
Did you disable the combo's row source as an experiment?
 

bastanu

AWF VIP
Local time
Today, 00:42
Joined
Apr 13, 2010
Messages
1,401
Please see if this sample makes it easier to follow.
Cheers,
 

Attachments

  • Database48.accdb
    476 KB · Views: 183

MajP

You've got your good things, and you've got mine.
Local time
Today, 03:42
Joined
May 21, 2018
Messages
8,463
The combo box reads about 2700 records
The subform reads about 2000 records when not filtered and when the query runs the result is almost instantanious
So the query is very basic
These are great ideas, and might fix it. I cannot imagine this is slow because you are loading that recordsource. I have to imagine other things are going on. I would do a quick test. Rebuild a dummy form from scratch with the same recordsource and combo. It does not have to be pretty, but enough to load the subform and query it with the combo. If that is fast, then I would consider using this to rebuild the form.
 

Users who are viewing this thread

Top Bottom