How to get value from a List Box?

  • Thread starter Thread starter Marc Meltzer
  • Start date Start date
M

Marc Meltzer

I wish to get the value that is stored in the first row of a list box.
How do I do this?

I've tried the ItemData property, which seemed like the most logical
one, but that didn't seem to do the trick.

Thanks!
Marc
 
Marc,
What code did you use, and where did you place that code?

Setting the DefaultValue of the listbox to...
lstYourListName.ItemData(0)
would cause the first selection in the list to be entered on any new record.
(Multi-Select set to None)
Or...
Something = lstYourListName
should represent the value you have already selected in that field ("bound"
to a field in your table)
 
I am trying to insert some data into a table. One of the values I am
inserting is the single value returned by another query. The simplest
way I thought to do this was run the inner query, placing the result in
some control (I thought a list- or combobox would work best). Then I
would pass the first item as a parameter to the outer query.

I am putting the code behind a command button. For whatever reason, all
I'm getting is NULL for any property of the listbox.

If I set the default value to 0, I at least get 0 as a result, but that
doesn't help me.

Where else should I look?

Marc
 
Never mind. The problem was I was calling for the value from the
listbox before I ran the query, so of course there was nothing to list.
As soon as I moved the code around, everything worked fine.

Marc
 
Back
Top