Hide subform in case statement (1 Viewer)

Tupacmoche

Registered User.
Local time
Yesterday, 19:10
Joined
Apr 28, 2008
Messages
291
Hi All,

I have a form that has a combobox to select many subforms below it. The on load event sets their visibility to False so they are hidden when the main form opens. But after selecting the first one with the code:
Select Case [CboHowPay]
Case "Check"
Me.TransmittalCkInfo_subform.Visible = True
and then selecting a second, third all the forms remain visable. How can, I change their Visability to false when selecting a different subform. Here is the entire case statement:

Private Sub CboHowPay_Change()

Select Case [CboHowPay]
Case "Check"
Me.TransmittalCkInfo_subform.Visible = True
Case "Cash"
Me.TransmittalCCInfo_subform.Visible = False
Case "Credit Card"
Me.TransmittalCCInfo_subform.Visible = True
Case "Wire (EFT)"
Me.TransmittalCCInfo_subform.Visible = False
Case "Securities"
Me.TransmittalCCInfo_subform.Visible = False
Case "Gift-In-Kind"
Me.TransmittalGIKInfo_subform.Visible = True
Case "ACH"
Me.TransmittalCCInfo_subform.Visible = True

End Select

End Sub:banghead:
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 16:10
Joined
Aug 30, 2003
Messages
36,124
You'd have to set the visibility of all the non-selected subforms to false. Presuming only one shows at a time, I'd probably have a single subform control and set its source object to the appropriate form.
 

Tupacmoche

Registered User.
Local time
Yesterday, 19:10
Joined
Apr 28, 2008
Messages
291
Hi Paul,

Is there code like CurrentSubform Set Visable = False ? This way whatever is currently visable will be hidden before the case statement changes the selected subform to visable?
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 16:10
Joined
Aug 30, 2003
Messages
36,124
I suppose you could loop and hide them all first, but I'd go the other way. It can be a performance drag to load 7 subforms.
 

Tupacmoche

Registered User.
Local time
Yesterday, 19:10
Joined
Apr 28, 2008
Messages
291
Sorry, I was not clear but this is what, I had in mind. When a selection is made right before making any subform visable code is run to change the viability for whatever the current subform may be to false. So, in the case statement below where the case is "Check" something like : Me.CurrentSubform = False This run for all case statements and hides whatever current subform is visable. Is there code to do that?:eek:

Private Sub CboHowPay_Change()

Select Case [CboHowPay]
Case "Check"
Me.CurrentSubform = False
Me.TransmittalCkInfo_subform.Visible = True
Case "Cash"
Me.TransmittalCCInfo_subform.Visible = False
Case "Credit Card"
Me.TransmittalCCInfo_subform.Visible = True
Case "Wire (EFT)"
Me.TransmittalCCInfo_subform.Visible = False
Case "Securities"
Me.TransmittalCCInfo_subform.Visible = False
Case "Gift-In-Kind"
Me.TransmittalGIKInfo_subform.Visible = True
Case "ACH"
Me.TransmittalCCInfo_subform.Visible = True

End Select

End Sub
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 16:10
Joined
Aug 30, 2003
Messages
36,124
You were clear, I'm not aware of any way to refer to the currently visible subform other than looping them all. I guess I wasn't clear that it's much more efficient to load a single subform than 7, and change the subform as desired.

Me.SubformControlName.SourceObject = "FormName"
 

Users who are viewing this thread

Top Bottom