OnClick Combo Box Making a List Box Visible

dntel123

Registered User.
Local time
Today, 17:08
Joined
Feb 23, 2007
Messages
35
Hey,

Hopefully this is an easy question: I have a Combo Box (Combo2) and its linked to a Query which populates it with 4 items from a table called tblModules.

What i cant figure out the syntax for is when i select an item in the combo box it will then change a List Boxes Visibility to = True

So for example,
Code:
if item in combo box clicked then lstNetworking.Visible = True
I need this because i have 4 List Boxes with Visibility set to False, on top of each other, and i want to use the combo box to select a Module which will then make the appropriate List Box Visible which will be populated with contact information.

So far i got this which just throws me an Invalid Qualifier Error:

Code:
Private Sub Combo2_Click()
If Me.Combo2.OnClick = "Networking" Then lstNetworking.Visible = True

End Sub
Help Greatly Appreciated :)
 
Code:
Private Sub cboX_Change()

  HideLists Me
  
  Select Case Me.cboX.Value
    Case "networking"
      Me.ListNetworking.Visible = True
    Case "X"
      Me.ListX.Visible = True
    Case "Y"
      Me.ListY.Visible = True
  End Select

End Sub

Sub HideLists(myFrm As Form)
' http://msdn.microsoft.com/en-us/library/aa224135(office.11).aspx

  Dim ctl As Control
  For Each ctl In myFrm
    If ctl.ControlType = acListBox Then
      ctl.Visible = False
    End If
  Next
  
End Sub
 
Alternatively...
Code:
Private Sub cbox_AfterUpdate()
   Me!ListX.Visible = (Me!cbox="X")
   Me!ListY.Visible = (Me!cbox="Y")
End Sub

So ListX becomes visible whenever cbox="X" and becomes invisble whenever it doesn't, etc.
 
Thanks both of you, I've got it working nw perfectly now thank you!
 

Users who are viewing this thread

Back
Top Bottom