Populating a List Box based on value from another List Box

  • Thread starter Thread starter sara
  • Start date Start date
S

sara

I want to populate a list box based on a selected parameter from another list
box.
I have been trying to do something like this in my OnClick routine of my
source listbox;

Public Sub List1_Click()

Dim ID As Integer
myID = List1.Column(0) // This correctly gives me the selected value

/*Now i want to use the below SQL statement to help me somehow populate the
destination list box*/
select field1,field2,field3,field4
from mytable
where AppID=myID

End Sub

An alternate way (which also has failed) could be to set the row source of
the destination list box. What i tried to do was to write the above select
statement as it is:
select field1,field2,field3,field4
from mytable
where AppID=List1.Column(0)
And i get an error in the last line:((((
Can someone help me out with this
 
The reason your alternative solution does not appear to work is because you
have to requery the second list box when you make a change to the first. So
in the After Update event of List1, requery List2.
 
Back
Top