Open multiple instances of subform

Falcon88

Registered User.
Local time
Today, 15:19
Joined
Nov 4, 2014
Messages
320
Hii all dears
I have an Access database with a main form that contains 9 subforms.
I created 9 tabs, each containing one subform, and each subform uses a parameter based on the tab it is located on.

All the subforms have the same record source and design, but they differ only by a single parameter.

This becomes very time-consuming and tiring when I need to change code, make modifications, or add features, because I have to edit all 9 subforms separately.

My question: What is the best way to design just one subform so that it opens in the selected tab and changes only the parameter accordingly?
 
Yes you should have one and only one form. In fact I would go further and say you only have one subform too.
What is the parameter? is is a filter?
 
You can take a subform and put it in front of the tab, not on a page in the tab. It will look like it is on the page, but since it is in front it will seem as if it is on all pages. Then when you change the tab control all you are really doing is modifying the source object. The other way is to have 9 subform controls with the same source object, and modify each one of those. That is not quite as efficient and time saving.
 
You can take a subform and put it in front of the tab, not on a page in the tab. It will look like it is on the page, but since it is in front it will seem as if it is on all pages. Then when you change the tab control all you are really doing is modifying the source object. The other way is to have 9 subform controls with the same source object, and modify each one of those. That is not quite as efficient and time saving.
Can you give me a sample ?
 
Yes you should have one and only one form. In fact I would go further and say you only have one subform too.
What is the parameter? is is a filter
Really the record source is a query with one condition related to the page index no
And there a combobox on that subform filtered by the page index no
 
One main form, one subform and in the subform control properties, set the link child/master properties to set the filter
 
Can you give me a sample ?
I have the subform hanging over the tab so you can see what is going on. If you make the tab wider then it appears on the tab.
 

Attachments

Here is another example. You say you have nine tabs now. But maybe this could grow to 15, or 20. If that is the case you can add 20 tabs now and then configure the ones you use at runtime. It could pull this data from a table.

In this example a law firm has a different number of partners. When you pick a law firm it configures a tab for each partner based on data in the table. Then it does a similar filtering to that in the other example.
 

Attachments

THANKS FOR ALL

CAN I GET THE SUM OF SOME COLOMUNS ON THAT SUBFORMS TO A TEXT BOX ON THE MAINFORM AND WHY ?
 
THANKS FOR ALL

CAN I GET THE SUM OF SOME COLOMUNS ON THAT SUBFORMS TO A TEXT BOX ON THE MAINFORM AND WHY ?
Yes but DO NOT SHOUT AT ME

On the Subform you need an Unbound Control to Sum whatever you need.
Then on the Main Form you need to use a Forms Reference like:-

=[Forms]![MainFormName]![NameofSubform].[Form]![nameofControlthatIsdoingTheSum]
 
Yes but DO NOT SHOUT AT ME

On the Subform you need an Unbound Control to Sum whatever you need.
Then on the Main Form you need to use a Forms Reference like:-

=[Forms]![MainFormName]![NameofSubform].[Form]![nameofControlthatIsdoingTheSum]

Good this works good if there multi subforms uses multiple rowsources .

But i use same subform with multiple tabs with same rowsource but filterd
 
Good this works good if there multi subforms uses multiple rowsources .

But i use same subform with multiple tabs with same rowsource but filter
Good this works good if there multi subforms uses multiple rowsources .

But i use same subform with multiple tabs with same rowsource but filterd
OK Can you upload a copy of the database?
 
Good this works good if there multi subforms uses multiple rowsources .

But i use same subform with multiple tabs with same rowsource but filterd
So unless you are summing different fields per subform, it would be the same?
Otherwise tailor the summing per page number.
I would have thought just a DSum on filter of the subform as criteria?
 
Good this works good if there multi subforms uses multiple rowsources .

But i use same subform with multiple tabs with same rowsource but filterd
Every copy of your subform will have a different subform control name which is used in the expression provided by @mike60smart
 
Good this works good if there multi subforms uses multiple rowsources .

But i use same subform with multiple tabs with same rowsource but filterd
Using MajP's example in the Footer of the Subform for Partners add the following Unbound Control:-
=DSum("Total","tblPartners","PartnerID = " & [PartnerID])

Total being a field in tblPartners with a numeric value for each record.
 

Attachments

In the attached I created a query to get the Total field from tblPartners.

Then in the Subform I added a subform based on qryTotals to obtain the Grand Total for All Partners related to the Form selected.

The Guru's will have a slicker method.
 

Attachments

I would add a control on your mainform and then with the code you already have
Code:
Private Sub TabCtl2_Change()
  FilterSubform
  Me.txtTotal = DSum("Extension", "Employees", Me.subFrmOrders.Form.Filter) ' Add this line, amending for field and table. I just used what was there.
End Sub
 

Users who are viewing this thread

Back
Top Bottom