ItemsSelected in List Box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm having a problem with the ItemsSelected.Count. I have two list boxes on a form. The first list box contains a list of tasks. The second list box I want to be blank until a task is selected from the first list box. When a task is selected, I want the second list box to be enabled (which I know how to do) and to display all of the actions associated with that task. I have the correct tables, and know how to set up the queries to fill the second list box. The only problem is I can't find a procedure to trigger my code after the item was selected in the first list box. I tried the After Update Event, as well as Click and MouseDown. The code within these event procedures is called, but ItemsSelected.Count is still zero because the event procedures are called before the actual selection of the item is registered. Can someone help me figure out where to place my code so that I can tell which item was selected as soon as it was selected? Thanks!
 
Hi,
If your list box is NOT multi select, just use the AfterUpdate event and grab the selected value with:
Me.yourListBox

If it is multi-select, the AfterUpdate event does report the correct count of selected items for me using Acc2k.
If however, the listbox IS NOT Multiselect and you try to get the count, it will always be zero!!

HTH
Dan Artuso, MVP

jakeup said:
I'm having a problem with the ItemsSelected.Count. I have two list boxes on a form. The first list box contains a list of
tasks. The second list box I want to be blank until a task is selected from the first list box. When a task is selected, I want
the second list box to be enabled (which I know how to do) and to display all of the actions associated with that task. I have
the correct tables, and know how to set up the queries to fill the second list box. The only problem is I can't find a procedure
to trigger my code after the item was selected in the first list box. I tried the After Update Event, as well as Click and
MouseDown. The code within these event procedures is called, but ItemsSelected.Count is still zero because the event procedures
are called before the actual selection of the item is registered. Can someone help me figure out where to place my code so that I
can tell which item was selected as soon as it was selected? Thanks!
 
Back
Top