Making subforms visible by combo box

  • Thread starter Thread starter ssmithri
  • Start date Start date
S

ssmithri

Greetings,

I am trying to hide/unhide subforms based on a value in a combobox. M
forms are named exactly as the values in the combo.

Here is the code:

Private Sub flp_Change()
Dim rs As String
rs = (Me.flp.Value) <-- this is the value in the combobox

If Me.flp.Value = rs Then
Me(rs).Form.Visible = True
Else
Me(rs).Form.Visible = False
End If

End Sub

This actually works, however, all previously "unhidden" subforms sta
on the screen.

Any thoughts? Thanks
 
I can't be false... that is why I need help.

When the value in the combo box changes, I am trying to hide the old
form and make visible the one that was selected.

Am I attempting to do the impossible?
 
I can't be false... that is why I need help.

When the value in the combo box changes, I am trying to hide the old
form and make visible the one that was selected.

Am I attempting to do the impossible?
 
I figured it out...

I set all of the forms default visible property to No

In the OnChange event I put...

Private Sub flp_Change()
Dim rs As String
rs = (Me.flp.Value) <---- Combobox value
Me(rs).Form.Visible = True
Me.fno.Value = (rs) <---- Unbound control on form

End Sub

And on OnClick event I put...

Private Sub flp_Click()
Dim rsc As String
rsc = (Me.fno.Value)
Me(rsc).Form.Visible = False
End Sub

Now, everytime I change the value in the combobox, the old form hides
and the selected subform becomes visible.
 
I figured it out...

I set all of the forms default visible property to No

In the OnChange event I put...

Private Sub flp_Change()
Dim rs As String
rs = (Me.flp.Value) <---- Combobox value
Me(rs).Form.Visible = True
Me.fno.Value = (rs) <---- Unbound control on form

End Sub

And on OnClick event I put...

Private Sub flp_Click()
Dim rsc As String
rsc = (Me.fno.Value)
Me(rsc).Form.Visible = False
End Sub

Now, everytime I change the value in the combobox, the old form hides
and the selected subform becomes visible.
 
Back
Top