Selecting Listbox items in code

  • Thread starter Thread starter Malbo
  • Start date Start date
M

Malbo

I am trying to use a listbox click event to run VBA code which selects an
item in another listbox.

Private Sub List0_Click()

Select Case List0.Value
Case "CR2"

List2.SetFocus

List2.ListIndex = 0

Case "CR2(E)"

List2.SetFocus

List2.ListIndex = 1
Case "TRACER"

List2.SetFocus

List2.ListIndex = 2
End Select


End Sub

The code works and does select the specified item from the second listbox.

but .... No item is selected in the first listbox. Why not? How can I
highlight the subject of the original click??

Can I chain a series of listboxes in this way?
 
Thanks for your quick reply.

I am investigating the performance of alternative vehicle configurations so
I want to select from a range of vehicles (List0) and a range of
configurations for each vehicle (List2).

I want to start my program by selecting a vehicle with a known initial
configuration hence I want to set List2 based on a selection from List0.

I can then select alternative configurations from list 2 as I need them.

As I develop this application I want to add more detail to my configurations
so adding more listboxes to my model.
 
Malbo said:
I am trying to use a listbox click event to run VBA code which selects an
item in another listbox.

Private Sub List0_Click()

Select Case List0.Value
Case "CR2"

List2.SetFocus

List2.ListIndex = 0

Case "CR2(E)"

List2.SetFocus

List2.ListIndex = 1
Case "TRACER"

List2.SetFocus

List2.ListIndex = 2
End Select


End Sub

The code works and does select the specified item from the second listbox.

but .... No item is selected in the first listbox. Why not? How can I
highlight the subject of the original click??

Can I chain a series of listboxes in this way?
 
Back
Top