Newbie list box question

  • Thread starter Thread starter Al
  • Start date Start date
A

Al

I have a simple list box with 5 values in it, what i want
to do is display a particular hidden list box, depending
on which value is chosen from the original list box.
 
In the AfterUpdate event of the first list box, put code that checks what
value's been selected, and toggle the visibility of the other listbox based
on that.

Your code would be something along the lines of:

Private Sub List0_AfterUpdate()

Me.List1.Visible = (Me.List0 = "First Item")
Me.List2.Visible = (Me.List0 = "Second Item")
Me.List3.Visible = (Me.List0 = "Third Item")
Me.List4.Visible = (Me.List0 = "Fourth Item")
Me.List5.Visible = (Me.List0 = "Fifth Item")

End Sub

Note that this will only work if List0 is not set to allow Multiselect. The
reason for setting the visibility of each of the other 5 listboxes is to
ensure that they're hidden if they were previously visible and no longer
should be.
 
You want to make a second listbox visible depending on the value in
the first lisbox?

Create a function in the form module and call it from your form
OnCurrent and listbox control AfterUpdate event procedure. In the
function put the code

If MyListbox1 = "some value" then
MyListbox2.visible = True
Else
MyListbox2.visible = False
End If

Hope this helps,

Peter De Baets
Peter's Software - MS Access Tools for Developers
http://www.peterssoftware.com
 
Back
Top