Selecting Listbox items in code

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?
 
M

Malbo

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.
 
Y

yy

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?
 

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

Similar Threads


Top