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 7 12181
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
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
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
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 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.
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
Thanks for the advice Allen.
Makes sense in the scope of my app.
Greg This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: erikbower65 |
last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps:
1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal.
2. Connect to...
|
by: linyimin |
last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
|
by: erikbower65 |
last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA:
1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
|
by: Taofi |
last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same
This are my field names
ID, Budgeted, Actual, Status and Differences
...
|
by: DJRhino1175 |
last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this -
If...
|
by: Rina0 |
last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
|
by: DJRhino |
last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer)
If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _
310030356 Or 310030359 Or 310030362 Or...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: lllomh |
last post by:
How does React native implement an English player?
| |