Combo box opening non-visible subfrms on tab control

D

dudyone

Have Main form with combo box and other info
I have a combo box with the selections of
Charpy Base
CharpyHAZ
Charpy Weld
Tensile Base
Tensile Weld
Chemical Base
Chemical Mill
Chemical Weld
Bends Weld



I have put the following code in the AfterUpdate of combo box.
All nine subforms are stacked on Tab Control under the first Tab named
Testing
My subform also have tabs named Customer, Specs, MTR Statements that are not
tied to the combo box.
All nine subforms Visible is set to no
When I open the main form everything looks good the tab control shows
my Customer tab, Specs tab, and MTR Statements tab.
When I chose one of the selections in combo box nothing happens.
I want the appropriate subform to open for data.
Whats wrong with the code

Private Sub Cmb_TestType_AfterUpdate()

Select Case Cmb_TestType

Case Charpy_Base
Me.SubFrm_CharpyBase.Visible = True
Me.SubFrm_CharpyBase.Visible = False

Case Charpy_HAZ
Me.SubFrm_CharpyHAZ.Visible = True
Me.SubFrm_CharpyHAZ.Visible = False

Case Charpy_Weld
Me.SubFrm_CharpyWeld.Visible = True
Me.SubFrm_CharpyWeld.Visible = False

Case Tensile_Base
Me.SubFrm_TensileBase.Visible = True
Me.SubFrm_TensileBase.Visible = False

Case Tensile_Weld
Me.SubFrm_TensileWeld.Visible = True
Me.SubFrm_TensileWeld.Visible = False

Case ChemicaL_Base
Me.SubFrm_ChemicalBase.Visible = True
Me.SubFrm_ChemicalBase.Visible = False

Case Chemical_Mill
Me.SubFrm_ChemicalMill.Visible = True
Me.SubFrm_ChemicalMill.Visible = False

Case Chemical_Weld
Me.SubFrm_ChemicalWeld.Visible = True
Me.SubFrm_ChemicalWeld.Visible = False

Case Bends_Weld
Me.SubFrm_BendsWeld.Visible = True
Me.SubFrm_BendsWeld.Visible = False

End Select
End Sub
 
K

kingston via AccessMonster.com

When you set the .Visible property to True, the subform becomes visible, but
you set it right back to False. So, it disappears probably before you can
even notice. I think you want this for each case:

Case Subform1
Me.Subform1.Visible = True
Me.Subform2.Visible = False
Me.Subform3.Visible = False
Me.Subform4.Visible = False
...
Case Subform2
Me.Subform1.Visible = False
Me.Subform2.Visible = True
Me.Subform3.Visible = False
...
 
D

dudyone

Kingston,

Sorry I posted a new message
Please disregard

I changed the code and still nothing happens.
I have my Testing ctl tab set to Visible no
and added the following code to the
OnClick of the combo box

Private Sub Cmb_TestType_OnClick()
Me.TabCtl_Testing.Visible = True
End Sub
Even if I set the Testing tab crl to visible yes
and I make a selection in the combo box,
nothing happens.

Can you have 2 Event Procedures in the same control?
Thanks

When you set the .Visible property to True, the subform becomes visible, but
you set it right back to False. So, it disappears probably before you can
even notice. I think you want this for each case:

Case Subform1
Me.Subform1.Visible = True
Me.Subform2.Visible = False
Me.Subform3.Visible = False
Me.Subform4.Visible = False
...
Case Subform2
Me.Subform1.Visible = False
Me.Subform2.Visible = True
Me.Subform3.Visible = False
...
Have Main form with combo box and other info
I have a combo box with the selections of
[quoted text clipped - 62 lines]
End Select
End Sub
 
K

kingston via AccessMonster.com

A control may have multiple procedures based on multiple events or a single
event can execute multiple procedures via subroutines and functions. I'm not
sure that this is what you're looking for though.

Anyway, I think you should use the After Update event for your combo box
instead of the On Click event. HTH.
Kingston,

Sorry I posted a new message
Please disregard

I changed the code and still nothing happens.
I have my Testing ctl tab set to Visible no
and added the following code to the
OnClick of the combo box

Private Sub Cmb_TestType_OnClick()
Me.TabCtl_Testing.Visible = True
End Sub
Even if I set the Testing tab crl to visible yes
and I make a selection in the combo box,
nothing happens.

Can you have 2 Event Procedures in the same control?
Thanks
When you set the .Visible property to True, the subform becomes visible, but
you set it right back to False. So, it disappears probably before you can
[quoted text clipped - 17 lines]
 
D

dudyone via AccessMonster.com

'Help what's wrong with my code
'CmbTestType is a Combo box with [Event Procedure] in
' the AfterUpdate(). I have the following listed in RowSource &
' it works fine.
' "" blank
' Charpy Base
' Charpy HAZ
' Charpy Weld
' Tensile Base
' Tensile Weld
' Chemical Base
' Chemical Mill
' Chemcial Weld
' Bends Weld
'
' All 9 FrmSub's are stacked on a tab control (0)
' Other tabs are Customers, Specs, and MTR Statements.
' When I select the TestType Combo Box it is supose to activate
' a form to enter data.
' Testing.Visible is the first tab on the tab control
' It becomes visible when I select the combo box, but
' the form does not load.
' Also the testing tab is not the first tab, the Customers tab is the
' one that is activated. I have to click the Testing tab to see if
' the form has loaded. I'm about to lost a good head of hair over this.
DuWayne

Private Sub CmbTestType_AfterUpdate()

Testing.Visible = True

Select Case CmbTestType

Case ""

Me.FrmSubCharpyBase.Visible = False
Me.FrmSubCharpyHAZ.Visible = False
Me.FrmSubCharpyWeld.Visible = False
Me.FrmSubTensileBase.Visible = False
Me.FrmSubTensileWeld.Visible = False
Me.FrmSubChemicalBase.Visible = False
Me.FrmSubChemicalMill.Visible = False
Me.FrmSubChemicalWeld.Visible = False
Me.FrmSubBendsWeld.Visible = False
Testing.Visible = False

Case Charpy_Base

Me.FrmSubCharpyBase.Visible = True
Me.FrmSubCharpyHAZ.Visible = False
Me.FrmSubCharpyWeld.Visible = False
Me.FrmSubTensileBase.Visible = False
Me.FrmSubTensileWeld.Visible = False
Me.FrmSubChemicalBase.Visible = False
Me.FrmSubChemicalMill.Visible = False
Me.FrmSubChemicalWeld.Visible = False
Me.FrmSubBendsWeld.Visible = False

Case Charpy_HAZ

Me.FrmSubCharpyBase.Visible = False
Me.FrmSubCharpyHAZ.Visible = True
Me.FrmSubCharpyWeld.Visible = False
Me.FrmSubTensileBase.Visible = False
Me.FrmSubTensileWeld.Visible = False
Me.FrmSubChemicalBase.Visible = False
Me.FrmSubChemicalMill.Visible = False
Me.FrmSubChemicalWeld.Visible = False
Me.FrmSubBendsWeld.Visible = False

Case Charpy_Weld

Me.FrmSubCharpyBase.Visible = False
Me.FrmSubCharpyHAZ.Visible = False
Me.FrmSubCharpyWeld.Visible = True
Me.FrmSubTensileBase.Visible = False
Me.FrmSubTensileWeld.Visible = False
Me.FrmSubChemicalBase.Visible = False
Me.FrmSubChemicalMill.Visible = False
Me.FrmSubChemicalWeld.Visible = False
Me.FrmSubBendsWeld.Visible = False

Case Tensile_Base

Me.FrmSubCharpyBase.Visible = False
Me.FrmSubCharpyHAZ.Visible = False
Me.FrmSubCharpyWeld.Visible = False
Me.FrmSubTensileBase.Visible = True
Me.FrmSubTensileWeld.Visible = False
Me.FrmSubChemicalBase.Visible = False
Me.FrmSubChemicalMill.Visible = False
Me.FrmSubChemicalWeld.Visible = False
Me.FrmSubBendsWeld.Visible = False

Case Tensile_Weld

Me.FrmSubCharpyBase.Visible = False
Me.FrmSubCharpyHAZ.Visible = False
Me.FrmSubCharpyWeld.Visible = False
Me.FrmSubTensileBase.Visible = False
Me.FrmSubTensileWeld.Visible = True
Me.FrmSubChemicalBase.Visible = False
Me.FrmSubChemicalMill.Visible = False
Me.FrmSubChemicalWeld.Visible = False
Me.FrmSubBendsWeld.Visible = False

Case ChemicaL_Base

Me.FrmSubCharpyBase.Visible = False
Me.FrmSubCharpyHAZ.Visible = False
Me.FrmSubCharpyWeld.Visible = False
Me.FrmSubTensileBase.Visible = False
Me.FrmSubTensileWeld.Visible = False
Me.FrmSubChemicalBase.Visible = True
Me.FrmSubChemicalMill.Visible = False
Me.FrmSubChemicalWeld.Visible = False
Me.FrmSubBendsWeld.Visible = False

Case Chemical_Mill

Me.FrmSubCharpyBase.Visible = False
Me.FrmSubCharpyHAZ.Visible = False
Me.FrmSubCharpyWeld.Visible = False
Me.FrmSubTensileBase.Visible = False
Me.FrmSubTensileWeld.Visible = False
Me.FrmSubChemicalBase.Visible = False
Me.FrmSubChemicalMill.Visible = True
Me.FrmSubChemicalWeld.Visible = False
Me.FrmSubBendsWeld.Visible = False

Case Chemical_Weld

Me.FrmSubCharpyBase.Visible = False
Me.FrmSubCharpyHAZ.Visible = False
Me.FrmSubCharpyWeld.Visible = False
Me.FrmSubTensileBase.Visible = False
Me.FrmSubTensileWeld.Visible = False
Me.FrmSubChemicalBase.Visible = False
Me.FrmSubChemicalMill.Visible = False
Me.FrmSubChemicalWeld.Visible = True

Case Bends_Weld

Me.FrmSubCharpyBase.Visible = False
Me.FrmSubCharpyHAZ.Visible = False
Me.FrmSubCharpyWeld.Visible = False
Me.FrmSubTensileBase.Visible = False
Me.FrmSubTensileWeld.Visible = False
Me.FrmSubChemicalBase.Visible = False
Me.FrmSubChemicalMill.Visible = False
Me.FrmSubChemicalWeld.Visible = False
Me.FrmSubBendsWeld.Visible = True

End Select

End Sub
Kingston,

Sorry I posted a new message
Please disregard

I changed the code and still nothing happens.
I have my Testing ctl tab set to Visible no
and added the following code to the
OnClick of the combo box

Private Sub Cmb_TestType_OnClick()
Me.TabCtl_Testing.Visible = True
End Sub
Even if I set the Testing tab crl to visible yes
and I make a selection in the combo box,
nothing happens.

Can you have 2 Event Procedures in the same control?
Thanks
When you set the .Visible property to True, the subform becomes visible, but
you set it right back to False. So, it disappears probably before you can
[quoted text clipped - 17 lines]
 
K

kingston via AccessMonster.com

If your combobox entries are strings and you want to refer to them directly,
you need to spell them out exactly as they appear in the combobox with
quotation marks around them. Otherwise, you can use variables that carry the
string values and not use quotation marks. It appears that this might be the
problem. Also, consider using Case Else instead of "" for a blank entry.

So, if you do not use variables and your combobox entries are: Charpy Base,
Charpy HAZ...
you need to have select statements that look like this:
Select Case Me.ComboboxControl
Case "Charpy Base"
...
Case "Charpy HAZ"
...
Do not add spaces, underscores, etc. unless you have created variables that
reference the actual strings.
'Help what's wrong with my code
'CmbTestType is a Combo box with [Event Procedure] in
' the AfterUpdate(). I have the following listed in RowSource &
' it works fine.
' "" blank
' Charpy Base
' Charpy HAZ
' Charpy Weld
' Tensile Base
' Tensile Weld
' Chemical Base
' Chemical Mill
' Chemcial Weld
' Bends Weld
'
' All 9 FrmSub's are stacked on a tab control (0)
' Other tabs are Customers, Specs, and MTR Statements.
' When I select the TestType Combo Box it is supose to activate
' a form to enter data.
' Testing.Visible is the first tab on the tab control
' It becomes visible when I select the combo box, but
' the form does not load.
' Also the testing tab is not the first tab, the Customers tab is the
' one that is activated. I have to click the Testing tab to see if
' the form has loaded. I'm about to lost a good head of hair over this.
DuWayne

Private Sub CmbTestType_AfterUpdate()

Testing.Visible = True

Select Case CmbTestType

Case ""

Me.FrmSubCharpyBase.Visible = False
Me.FrmSubCharpyHAZ.Visible = False
Me.FrmSubCharpyWeld.Visible = False
Me.FrmSubTensileBase.Visible = False
Me.FrmSubTensileWeld.Visible = False
Me.FrmSubChemicalBase.Visible = False
Me.FrmSubChemicalMill.Visible = False
Me.FrmSubChemicalWeld.Visible = False
Me.FrmSubBendsWeld.Visible = False
Testing.Visible = False

Case Charpy_Base

Me.FrmSubCharpyBase.Visible = True
Me.FrmSubCharpyHAZ.Visible = False
Me.FrmSubCharpyWeld.Visible = False
Me.FrmSubTensileBase.Visible = False
Me.FrmSubTensileWeld.Visible = False
Me.FrmSubChemicalBase.Visible = False
Me.FrmSubChemicalMill.Visible = False
Me.FrmSubChemicalWeld.Visible = False
Me.FrmSubBendsWeld.Visible = False

Case Charpy_HAZ

Me.FrmSubCharpyBase.Visible = False
Me.FrmSubCharpyHAZ.Visible = True
Me.FrmSubCharpyWeld.Visible = False
Me.FrmSubTensileBase.Visible = False
Me.FrmSubTensileWeld.Visible = False
Me.FrmSubChemicalBase.Visible = False
Me.FrmSubChemicalMill.Visible = False
Me.FrmSubChemicalWeld.Visible = False
Me.FrmSubBendsWeld.Visible = False

Case Charpy_Weld

Me.FrmSubCharpyBase.Visible = False
Me.FrmSubCharpyHAZ.Visible = False
Me.FrmSubCharpyWeld.Visible = True
Me.FrmSubTensileBase.Visible = False
Me.FrmSubTensileWeld.Visible = False
Me.FrmSubChemicalBase.Visible = False
Me.FrmSubChemicalMill.Visible = False
Me.FrmSubChemicalWeld.Visible = False
Me.FrmSubBendsWeld.Visible = False

Case Tensile_Base

Me.FrmSubCharpyBase.Visible = False
Me.FrmSubCharpyHAZ.Visible = False
Me.FrmSubCharpyWeld.Visible = False
Me.FrmSubTensileBase.Visible = True
Me.FrmSubTensileWeld.Visible = False
Me.FrmSubChemicalBase.Visible = False
Me.FrmSubChemicalMill.Visible = False
Me.FrmSubChemicalWeld.Visible = False
Me.FrmSubBendsWeld.Visible = False

Case Tensile_Weld

Me.FrmSubCharpyBase.Visible = False
Me.FrmSubCharpyHAZ.Visible = False
Me.FrmSubCharpyWeld.Visible = False
Me.FrmSubTensileBase.Visible = False
Me.FrmSubTensileWeld.Visible = True
Me.FrmSubChemicalBase.Visible = False
Me.FrmSubChemicalMill.Visible = False
Me.FrmSubChemicalWeld.Visible = False
Me.FrmSubBendsWeld.Visible = False

Case ChemicaL_Base

Me.FrmSubCharpyBase.Visible = False
Me.FrmSubCharpyHAZ.Visible = False
Me.FrmSubCharpyWeld.Visible = False
Me.FrmSubTensileBase.Visible = False
Me.FrmSubTensileWeld.Visible = False
Me.FrmSubChemicalBase.Visible = True
Me.FrmSubChemicalMill.Visible = False
Me.FrmSubChemicalWeld.Visible = False
Me.FrmSubBendsWeld.Visible = False

Case Chemical_Mill

Me.FrmSubCharpyBase.Visible = False
Me.FrmSubCharpyHAZ.Visible = False
Me.FrmSubCharpyWeld.Visible = False
Me.FrmSubTensileBase.Visible = False
Me.FrmSubTensileWeld.Visible = False
Me.FrmSubChemicalBase.Visible = False
Me.FrmSubChemicalMill.Visible = True
Me.FrmSubChemicalWeld.Visible = False
Me.FrmSubBendsWeld.Visible = False

Case Chemical_Weld

Me.FrmSubCharpyBase.Visible = False
Me.FrmSubCharpyHAZ.Visible = False
Me.FrmSubCharpyWeld.Visible = False
Me.FrmSubTensileBase.Visible = False
Me.FrmSubTensileWeld.Visible = False
Me.FrmSubChemicalBase.Visible = False
Me.FrmSubChemicalMill.Visible = False
Me.FrmSubChemicalWeld.Visible = True

Case Bends_Weld

Me.FrmSubCharpyBase.Visible = False
Me.FrmSubCharpyHAZ.Visible = False
Me.FrmSubCharpyWeld.Visible = False
Me.FrmSubTensileBase.Visible = False
Me.FrmSubTensileWeld.Visible = False
Me.FrmSubChemicalBase.Visible = False
Me.FrmSubChemicalMill.Visible = False
Me.FrmSubChemicalWeld.Visible = False
Me.FrmSubBendsWeld.Visible = True

End Select

End Sub
Kingston,
[quoted text clipped - 21 lines]
 
D

dudyone via AccessMonster.com

Thanks Kingston
You are the MAN!!
It works great!

I have one more of many questions!
When I make my testing tab visible I have to click on
it to see the subforms to enter data.
What code do i need to add so when I make my
selection in the combo box the testing tab is the
current tab?
Thanks Again
If your combobox entries are strings and you want to refer to them directly,
you need to spell them out exactly as they appear in the combobox with
quotation marks around them. Otherwise, you can use variables that carry the
string values and not use quotation marks. It appears that this might be the
problem. Also, consider using Case Else instead of "" for a blank entry.

So, if you do not use variables and your combobox entries are: Charpy Base,
Charpy HAZ...
you need to have select statements that look like this:
Select Case Me.ComboboxControl
Case "Charpy Base"
...
Case "Charpy HAZ"
...
Do not add spaces, underscores, etc. unless you have created variables that
reference the actual strings.
'Help what's wrong with my code
'CmbTestType is a Combo box with [Event Procedure] in
[quoted text clipped - 158 lines]
 
K

kingston via AccessMonster.com

Use the combo box's After Update or On Enter event to set the focus to a
control in the desired tab:

Me.ControlInTab.SetFocus

Thanks Kingston
You are the MAN!!
It works great!

I have one more of many questions!
When I make my testing tab visible I have to click on
it to see the subforms to enter data.
What code do i need to add so when I make my
selection in the combo box the testing tab is the
current tab?
Thanks Again
If your combobox entries are strings and you want to refer to them directly,
you need to spell them out exactly as they appear in the combobox with
[quoted text clipped - 18 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top