listbox question

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

Albert D. Kallal

In the forms desing mode, just set the listbox default to whatever the first
value is.
 
J

Jeremy

How can I do that dynamically? The first value is never
the same depending on what was chosen in the combo box
 
A

Albert D. Kallal

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)
 
J

Jeremy

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)
 

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