473,416 Members | 1,659 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

Tab Control and Dynamic subForm Linking

I am using the following code in my TabControl to manage subform
loads. The code assigns the subForms SourceObject.

- Do I also need code to DeAssign the SourceObject when leaving the
Tab, I'm thinking the Table will stay open otherwise ???

- Do I also need to use code to Assign the Child&Master Links, or can
I just type the names into the subForms Control Property and just
depend on the SourceObject to link to Table???

- Do I need to toggle the subForms Visible property when entering and
leaving the tab??? I thought I read this somewhere?
Private Sub tabPersonnel_Change()
'************************************************* *****
' PageTab Management
Select Case Me.tabPersonnel.Value
Case Me.pgGeneral.PageIndex
'mainform
strSelection = "GENERAL"
Case Me.PgPersonal.PageIndex
'mainform
strSelection = "PERSONAL"
Case Me.PgPromotions.PageIndex
'subForm
strSelection = "PROMOTIONS"
Me.[subPROMO].Visible = True
Me.[subPROMO].SourceObject = "F-PROMO"
Case Me.pgCredentials.PageIndex
'subForm
strSelection = "CREDENTIALS"
Me.[subCRED].Visible = True
Me.[subCRED].SourceObject = "F-CRED"
Case Else
MsgBox "Dunno what to do with page "
End Select
End Sub

Thanks
Greg

Feb 24 '07 #1
7 12270
Why are you assigning the SourceObject like this? What's the purpose? Is it
to make the form load faster (because it doesn't have to load all subforms
at the start)? Is it to reduce memory usage?

Do you actually need multiple subforms loaded at once? It's a bit hard to
give advice without understanding what you want to achieve.

If you only need one subform loaded at a time, one approach is to place a
subform directly on the main form, i.e. not on any of the pages of the tab
control. In fact, the Height of the tab control will be just enough for the
tabs. Then for each Page in the tab control, set the page's Tag property to
the name of the form you want loaded into the subform control. You can then
load the correct subform by adding this line to the Change event of your tab
control:

Me.[Sub1].SourceObject = Me.[Tab1].Pages(Me.[Tab1].Value).Tag

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<Ap******@gmail.comwrote in message
news:11**********************@j27g2000cwj.googlegr oups.com...
>I am using the following code in my TabControl to manage subform
loads. The code assigns the subForms SourceObject.

- Do I also need code to DeAssign the SourceObject when leaving the
Tab, I'm thinking the Table will stay open otherwise ???

- Do I also need to use code to Assign the Child&Master Links, or can
I just type the names into the subForms Control Property and just
depend on the SourceObject to link to Table???

- Do I need to toggle the subForms Visible property when entering and
leaving the tab??? I thought I read this somewhere?
Private Sub tabPersonnel_Change()
'************************************************* *****
' PageTab Management
Select Case Me.tabPersonnel.Value
Case Me.pgGeneral.PageIndex
'mainform
strSelection = "GENERAL"
Case Me.PgPersonal.PageIndex
'mainform
strSelection = "PERSONAL"
Case Me.PgPromotions.PageIndex
'subForm
strSelection = "PROMOTIONS"
Me.[subPROMO].Visible = True
Me.[subPROMO].SourceObject = "F-PROMO"
Case Me.pgCredentials.PageIndex
'subForm
strSelection = "CREDENTIALS"
Me.[subCRED].Visible = True
Me.[subCRED].SourceObject = "F-CRED"
Case Else
MsgBox "Dunno what to do with page "
End Select
End Sub

Thanks
Greg
Feb 24 '07 #2
Why are you assigning the SourceObject like this? What's the purpose? Is it
to make the form load faster (because it doesn't have to load all subforms
at the start)? Is it to reduce memory usage?
Do you actually need multiple subforms loaded at once?
I am attempting to make the form load faster and reduce memory usage.
I did not realize that this code is reading multiple subforms at once,
I thought it would load a subform only when the tab was selected. The
SourceObject is assigned in the change event of the TabControl when a
tab is selected?
If you only need one subform loaded at a time, one approach is to place a
subform directly on the main form, i.e. not on any of the pages of the tab
control.
I read that there were two approaches. The one you mention and the
approach that I was following. And it seems to work, but I am not
sure about the questions I previously asked about.
In fact, the Height of the tab control will be just enough for the
tabs. Then for each Page in the tab control, set the page's Tag property to
the name of the form you want loaded into the subform control. You can then
load the correct subform by adding this line to the Change event of your tab
control:
Me.[Sub1].SourceObject = Me.[Tab1].Pages(Me.[Tab1].Value).Tag
I really do not understand how I should place the subform on the main
form. I will eventually have up to 10-subforms. Do they need to be
fully sized or do I place them reduced in size on the main form? Do I
set their visibility off? How do they wind up showing on my Page and
sized properly? When the user selects a different tab, should the
SourceObject for the last subform be set to ""? Do I need to Assign
and DeAssign the Child/Parent in code, or just manually set the
subform property?

Sorry for so many questions, but am struggling to make this happen ;)

Thanks Allen

Greg
Feb 24 '07 #3
If the goal is to reduce loading time and memory usage, reusing a single
subform control would be the logical choice.

If you put the subform control on the form before adding the tab control, it
is sitting directly on the form. You can also do it by selecting the subform
control in the Toolbox, and clicking outside the tab control (i.e. on the
form itself.)

Hopefully you understand the difference between a subform control (the
rectangle on your form where you load a subform), and a subform (the form
that gets loaded into the subform control, typically specified in the
SourceObject property of the subform control.)

Since there is only one subform control, and you load different forms into
it (depending on which tab the user clicked on), there is no need to set the
Visible property. Loading a new form into the subform control effectively
unloads the one that was there before.

For starters, you can place the subform control beside the tab control, type
the name of a form in to the Tag property of each Page of the tab control,
and then use that one line in the Change event of the tab control.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<Ap******@gmail.comwrote in message
news:11**********************@8g2000cwh.googlegrou ps.com...
>Why are you assigning the SourceObject like this? What's the purpose? Is
it
to make the form load faster (because it doesn't have to load all
subforms
at the start)? Is it to reduce memory usage?
Do you actually need multiple subforms loaded at once?

I am attempting to make the form load faster and reduce memory usage.
I did not realize that this code is reading multiple subforms at once,
I thought it would load a subform only when the tab was selected. The
SourceObject is assigned in the change event of the TabControl when a
tab is selected?
>If you only need one subform loaded at a time, one approach is to place a
subform directly on the main form, i.e. not on any of the pages of the
tab
control.

I read that there were two approaches. The one you mention and the
approach that I was following. And it seems to work, but I am not
sure about the questions I previously asked about.
>In fact, the Height of the tab control will be just enough for the
tabs. Then for each Page in the tab control, set the page's Tag property
to
the name of the form you want loaded into the subform control. You can
then
load the correct subform by adding this line to the Change event of your
tab
control:
Me.[Sub1].SourceObject = Me.[Tab1].Pages(Me.[Tab1].Value).Tag

I really do not understand how I should place the subform on the main
form. I will eventually have up to 10-subforms. Do they need to be
fully sized or do I place them reduced in size on the main form? Do I
set their visibility off? How do they wind up showing on my Page and
sized properly? When the user selects a different tab, should the
SourceObject for the last subform be set to ""? Do I need to Assign
and DeAssign the Child/Parent in code, or just manually set the
subform property?

Sorry for so many questions, but am struggling to make this happen ;)

Thanks Allen

Greg
Feb 24 '07 #4
If you put the subform control on the form before adding the tab control, it
is sitting directly on the form. You can also do it by selecting the subform
control in the Toolbox, and clicking outside the tab control (i.e. on the
form itself.)
Hate making excuses, but I can't seem to manipuate the control
(SendToBack) in such a way that it sits Totally behind the
TabControl. The problem is my first 2-Tabs DoNot use subForms, they
display txtBoxes of the MainForm. The new subForm Control that was
sent to the background keeps covering over this.
Also, I was Previously varying the size of the subForm Control on each
TabPage to suit my display requirement. I believe I lose that using
the single subForm control.
The concept is excellent, but unfortunately I'm too far into my app to
turn back time wise, but want to use this from the getgo on my next
venture.

If Your Inclined, I would really like to continue along the path I was
on (ie unique subForm control on each page, and assign the
SourceObject when selecting the Tab.
I'm too far into my app to turn back time wise.

I really appreciate all your advice :)

Would I need code to DeAssign the SourceObject when leaving the
Tab, I'm thinking the Table will stay open otherwise ???

Do I also need to use code to Assign the Child&Master Links, or can
I just type the names into the subForms Control Property and just
depend on the SourceObject to link to Table???

Do I need to toggle the subForms Visible property when entering and
leaving the tab??? I thought I read this somewhere?

Thanks Again Allen
Greg

Feb 24 '07 #5
Ap******@gmail.com wrote:
I am using the following code in my TabControl to manage subform
loads. The code assigns the subForms SourceObject.

- Do I also need code to DeAssign the SourceObject when leaving the
Tab, I'm thinking the Table will stay open otherwise ???

- Do I also need to use code to Assign the Child&Master Links, or can
I just type the names into the subForms Control Property and just
depend on the SourceObject to link to Table???

- Do I need to toggle the subForms Visible property when entering and
leaving the tab??? I thought I read this somewhere?
Private Sub tabPersonnel_Change()
'************************************************* *****
' PageTab Management
Select Case Me.tabPersonnel.Value
Case Me.pgGeneral.PageIndex
'mainform
strSelection = "GENERAL"
Case Me.PgPersonal.PageIndex
'mainform
strSelection = "PERSONAL"
Case Me.PgPromotions.PageIndex
'subForm
strSelection = "PROMOTIONS"
Me.[subPROMO].Visible = True
Me.[subPROMO].SourceObject = "F-PROMO"
Case Me.pgCredentials.PageIndex
'subForm
strSelection = "CREDENTIALS"
Me.[subCRED].Visible = True
Me.[subCRED].SourceObject = "F-CRED"
Case Else
MsgBox "Dunno what to do with page "
End Select
End Sub

Thanks
Greg
Not sure if this will help in anyway. I shy away from tab forms as
they, for the most part, are a pita.

If you have a recordsource
Select custname, address, csz from table order by custname
you can't have a blank recordsource for the form unless you want to get
a bunch of #Name? indicators. But you could probably do
Select "" As CustName, "" As Address, "" As CSZ From Table
as the initial recordsource to create/pull up a blank record.

Another thing. Drop all of your subforms onto a form. Make all of
their visible properties false but the initial one. Then make some
buttons to simulate tabs. When you hit one, set all visible to false
but the one you want to make visible.

Feb 24 '07 #6
Okay, if your first 2 tabs do not use a subform, then the single generic
subform approach will not be suitable for this form (unless you can create
subforms for those 2 pages, which probably isn't your preferred design.)
Using different sized subforms is also an issue.

So, back to your original approach, with different subform controls on
different pages of the tab control. You can save the form with the
SourceObject property of the subforms left blank, and then assign the
property in the Change event of the subform if it has no already been
assigned:
With Me.[sbuPROMO]
If .SourceObject = vbNullString Then
.SourceObject = "F-PROMO"
End If
End With
and so on.

To answer your questions:
a) I would not deassign the SourceObject. Although it would save some
memory, you've already got the thing loaded, and the user is likely to come
back to the page.

b) When you assign the SourceObject, Access will have a guess at what you
need for LinkMasterFields/LinkChildFields. Just as at design time, it may
get it right (and if so it will probably be consistent) or it may not (in
which case you will need to assign the correct fields.)

c) There is no advantage in toggling the Visible property of the subform. It
doesn't show up anyway unless you are on that page, so it serves no purpose
to show/hide it.

HTH.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<Ap******@gmail.comwrote in message
news:11**********************@s48g2000cws.googlegr oups.com...
>If you put the subform control on the form before adding the tab control,
it
is sitting directly on the form. You can also do it by selecting the
subform
control in the Toolbox, and clicking outside the tab control (i.e. on the
form itself.)

Hate making excuses, but I can't seem to manipuate the control
(SendToBack) in such a way that it sits Totally behind the
TabControl. The problem is my first 2-Tabs DoNot use subForms, they
display txtBoxes of the MainForm. The new subForm Control that was
sent to the background keeps covering over this.
Also, I was Previously varying the size of the subForm Control on each
TabPage to suit my display requirement. I believe I lose that using
the single subForm control.
The concept is excellent, but unfortunately I'm too far into my app to
turn back time wise, but want to use this from the getgo on my next
venture.

If Your Inclined, I would really like to continue along the path I was
on (ie unique subForm control on each page, and assign the
SourceObject when selecting the Tab.
I'm too far into my app to turn back time wise.

I really appreciate all your advice :)

Would I need code to DeAssign the SourceObject when leaving the
Tab, I'm thinking the Table will stay open otherwise ???

Do I also need to use code to Assign the Child&Master Links, or can
I just type the names into the subForms Control Property and just
depend on the SourceObject to link to Table???

Do I need to toggle the subForms Visible property when entering and
leaving the tab??? I thought I read this somewhere?

Thanks Again Allen
Greg


Feb 25 '07 #7
Thanks for the advice Allen.
Makes sense in the scope of my app.

Greg

Feb 25 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Joshua Ammann | last post by:
Hi, (Using Access 2000) I have two tables, similar to Customers and Orders. (Not an exact parallel, but works for this example.) On a form showing customer data, there is a tab control. One...
7
by: kevin.jonas | last post by:
Let say I have a form called "frmMachineSpecs" witht wo subforms, "frmSpecs" and "frmMachines". Both subforms are in datasheet view. The first control in "frmSpecs" is "txtOEM_No". I want to...
3
by: Kranman | last post by:
Hi All, Love this site, have gotten a lot from it. This is my first time posting though, so forgive me for any errors. I have an Access 2000 db where I have a main form of Contractors and on...
1
by: RzB | last post by:
In a previous post in this NG (Oct 98) http://makeashorterlink.com/?D505347FB Henry Craven says that he was investigating a relationship between the presence or absence of a "Me!" prefix, the...
0
by: Pat Sagaser via .NET 247 | last post by:
I'm using a repeater with a dynamic template. I don't know the fields to display (or how many) until runtime. I have everything working except for linking Button events to the repeaters ItemCommand...
0
by: Mary | last post by:
I have a main form with one subform that is used to record test scores. The main form has the following fields: WratStudentID ( a combo box with 2 fields - student id and student name - . Stores...
7
by: Ajinkya | last post by:
I have writen a program for a game called game.exe Now it includes a player part to which has to be a function to be writen by someone else. Now I want to provide this exe to some tester who...
10
by: Chinde | last post by:
Hi I'm having problems with a subform, I'm using access 2007 but the DB's format is 2003, running os Xp. This is the problem, I have a main form which is set to be a single form and will auto...
4
beacon
by: beacon | last post by:
Hi everybody, I have a form (frmDeficiency) with a tab control (called deficiencyTabControl) that has 8 tabs. The first tab is for general information, but the 2nd through the 8th tabs have a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.