populating listboxes

P

prog

Hi,

I'm working on creating 3 cascading listboxes each based on the previous
selections.
I'm using the following code to populate a listbox AND this works to
populate my second listbox.

listbox 1 afterupdate: (used to populate list2)
Dim strSQL As String
strSQL = "Select name " _
& "From table2 " _
& "Where join_column = " & Me.[List1] & " " _
& "Order by name"
Me.[List2].RowSource = strSQL

The problem I'm running into is populating my third listbox based off of the
results of the second listbox.

listbox2 afterupdate: (used to populate third listbox)
Dim strSQL As String
strSQL = "Select name2 " _
& "From table3 " _
& "Where join_column = " & Me.[List2] & " " _
& "Order by name2"
Me.[List3].RowSource = strSQL

Why is my third list box not popluating, based off of second listbox
choices?
 
R

roger

if I understand you: you're trying to change the source of listboxes 2 and 3
when the user clicks on list box 1

but 3 doesn't change because changing the listbox source is not "updating"
the the control (i.e changing is VALUE) so the AfterUpdate event does not
fire.

If you're actually updating list2 (clicking on it) and nothing happens you
may have a corrupt form.
 
P

prog

Yes. So, what happens is this: I click listbox 1 (based on the code) it
populates Listbox2, then when I select a value from Listbox2 to update
Listbox3, nothing happens. Based on the code I have submitted below for
Listbox 2...it should activate data in Listbox3. So, I guess it could be a
corrupt form. But as far as the code is concerned it looks like I have the
correct code to update listbox 3 based on listbox 2?

roger said:
if I understand you: you're trying to change the source of listboxes 2 and 3
when the user clicks on list box 1

but 3 doesn't change because changing the listbox source is not "updating"
the the control (i.e changing is VALUE) so the AfterUpdate event does not
fire.

If you're actually updating list2 (clicking on it) and nothing happens you
may have a corrupt form.



prog said:
Hi,

I'm working on creating 3 cascading listboxes each based on the previous
selections.
I'm using the following code to populate a listbox AND this works to
populate my second listbox.

listbox 1 afterupdate: (used to populate list2)
Dim strSQL As String
strSQL = "Select name " _
& "From table2 " _
& "Where join_column = " & Me.[List1] & " " _
& "Order by name"
Me.[List2].RowSource = strSQL

The problem I'm running into is populating my third listbox based off of the
results of the second listbox.

listbox2 afterupdate: (used to populate third listbox)
Dim strSQL As String
strSQL = "Select name2 " _
& "From table3 " _
& "Where join_column = " & Me.[List2] & " " _
& "Order by name2"
Me.[List3].RowSource = strSQL

Why is my third list box not popluating, based off of second listbox
choices?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top