Delay a subform within a tabbed form (1 Viewer)

mounty76

Registered User.
Local time
Today, 04:24
Joined
Sep 14, 2017
Messages
341
Hi All,

I have a subform within a form, the subform shows data based on a query that uses the main form for its criteria, when I open the main form 'Accounts' it works fine without any issues and the subform shows what it should.

Problem I have is that the 'Accounts' main form is in a tab of a tabbed form, when I try to open the Accounts form in the tabbed form it comes up with errors asking for the query criteria, am guessing it is trying to open the subform before the Accounts form......not sure why it would do this in the tabbed form but when I just open the Accounts form it doesn't do it?

Any ideas greatly appreciated!!
 

Mike Krailo

Well-known member
Local time
Today, 07:24
Joined
Mar 28, 2020
Messages
1,044
Subform always opens first regaurdless where you open the form. If you use a navigation form that has a tab, you must reference the subform control for that tab. Then it will work inside the tab control but not outside the tab control like it does now. You cannot have it both ways.
 

mounty76

Registered User.
Local time
Today, 04:24
Joined
Sep 14, 2017
Messages
341
Thanks for this. If the subform opens first then how come when opening 'Accounts' form normally the subform shows the results of the query based on the data in the main form? Surely if the subform opened first then it would not have the data to run the query as the mainform isn't effectively open?

Anyway besides this I don't understand how it works opening the form directly but then when trying to open the same form from a navigation form it doesn't work 🤯
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 07:24
Joined
Feb 19, 2002
Messages
43,275
Surely if the subform opened first then it would not have the data to run the query as the mainform isn't effectively open?
The subform opens first. The master/child links are sync'd after the main form opens and that populates the subform correctly.
Anyway besides this I don't understand how it works opening the form directly but then when trying to open the same form from a navigation form it doesn't work
In a navigation form, the form becomes a subform and references to it have to go through the actual main form.

Forms!yourmainformname!yoursubformcontrolname.form!yourcontrolname

"yoursubformcontrolname" is the name of the subform control on the main form, NOT the name of the subform itself.
 

mounty76

Registered User.
Local time
Today, 04:24
Joined
Sep 14, 2017
Messages
341
Ah OK, thanks for this, so I just need to change the references in the query....am stacked out today but will let you know how it goes
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 07:24
Joined
Feb 19, 2002
Messages
43,275
The query in the subform won't work unless the mainform is loaded. To make this work, the main form has to open and then as you click on tabs, the specific subform gets loaded.
 

mounty76

Registered User.
Local time
Today, 04:24
Joined
Sep 14, 2017
Messages
341
I changed the reference in the query and it works fine now, thank you very much
 

spaLOGICng

Member
Local time
Today, 04:24
Joined
Jul 27, 2012
Messages
127
Hi All,

I have a subform within a form, the subform shows data based on a query that uses the main form for its criteria, when I open the main form 'Accounts' it works fine without any issues and the subform shows what it should.

Problem I have is that the 'Accounts' main form is in a tab of a tabbed form, when I try to open the Accounts form in the tabbed form it comes up with errors asking for the query criteria, am guessing it is trying to open the subform before the Accounts form......not sure why it would do this in the tabbed form but when I just open the Accounts form it doesn't do it?

Any ideas greatly appreciated!!
Rather than use a Tab Control, use a Navigation Control.

The Tab Control requires that you refer to it before referring to the parent form. To me, with all due respect, the Tab Control is archaic. I prefer the Navigation Control.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 07:24
Joined
Feb 19, 2002
Messages
43,275
The Tab Control requires that you refer to it before referring to the parent form. To me, with all due respect, the Tab Control is archaic. I prefer the Navigation Control.
I'm not sure why you would say that, the navigation control has exactly the same problem with referencing controls on a subform with the added twist that only a single subform is ever loaded at one time. Not all forms with tab controls are used as menus.
 

spaLOGICng

Member
Local time
Today, 04:24
Joined
Jul 27, 2012
Messages
127
I'm not sure why you would say that, the navigation control has exactly the same problem with referencing controls on a subform with the added twist that only a single subform is ever loaded at one time. Not all forms with tab controls are used as menus.
It is not a problem, per se, but by opting for the Navigation Control, which is already a sub form, it also accomplishes the same purpose as a Tab Control. You get the best of both worlds in one control and eliminate one layer of confusion.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 07:24
Joined
Feb 19, 2002
Messages
43,275
A form with a tab control can function as a navigation form but the opposite is not true. Tab controls do not have to contain subforms. They can be used to simplify the organization of a record with many fields
 

spaLOGICng

Member
Local time
Today, 04:24
Joined
Jul 27, 2012
Messages
127
A form with a tab control can function as a navigation form but the opposite is not true. Tab controls do not have to contain subforms. They can be used to simplify the organization of a record with many fields
And that is about the only time I will ever use a Tab Control. I will never use it to host a sub form but for maybe a limited number of exceptions.

I prefer the Navigation Control for a variety of reasons, but that is just my preference. I know a lot of people stay away from them, that is their preference.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 07:24
Joined
Feb 19, 2002
Messages
43,275
You can use whatever you prefer. I prefer to use tabbed forms to show a set of related data. Navigation forms are called "navigation" for a reason. They are intended to be a combination menu and data entry subform. I don't use navigation forms because I don't want to give up the real estate for the "menu" usage. I use menus/switchboards to control navigation through the application.
 

spaLOGICng

Member
Local time
Today, 04:24
Joined
Jul 27, 2012
Messages
127
You can use whatever you prefer. I prefer to use tabbed forms to show a set of related data. Navigation forms are called "navigation" for a reason. They are intended to be a combination menu and data entry subform. I don't use navigation forms because I don't want to give up the real estate for the "menu" usage. I use menus/switchboards to control navigation through the application.
Ok.
 

Users who are viewing this thread

Top Bottom