listbox question

  • Thread starter Thread starter Jeremy
  • Start date Start date
J

Jeremy

I have a list box that is populated by choosing something
in a combo box. This works fine. I want the first item
in the list box to be highlighted by default. It would
be just like a user clicked the top item.
So I need it to be highlighted and the value set for this
item without actually clicking on it.
 
In the forms desing mode, just set the listbox default to whatever the first
value is.
 
How can I do that dynamically? The first value is never
the same depending on what was chosen in the combo box
 
ah, ok, the listbox is not bound, or you are setting the sql for the listbox
(that detail you left out changes everthing!).


Ok, right after you fill/set the listbox, then use:

Me.List51.Selected(1) = True
Me.List51 = Me.List51.Column(0)

You have to both "select" the listbox (first line of above code) and also
"set" the value of the listbox also.

Also, watch the above, since if you don't have "headings", then Selected(1)
needs to be changed to selected(0)
 
Thanks alot man.

-----Original Message-----
ah, ok, the listbox is not bound, or you are setting the sql for the listbox
(that detail you left out changes everthing!).


Ok, right after you fill/set the listbox, then use:

Me.List51.Selected(1) = True
Me.List51 = Me.List51.Column(0)

You have to both "select" the listbox (first line of above code) and also
"set" the value of the listbox also.

Also, watch the above, since if you don't
have "headings", then Selected(1)
 
Back
Top