getting single selected value from listbox

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

Guest

Hi,

I have been trying to get the selected value returned from a listbox. Any
idea how to do it?
 
Are you trying to retrieve the bound value of the selected row in the
listbox, or the displayed value (these don't have to be the same, and seldom
are)?

You don't provide much to go on ... what have you been trying? What happens
(?error message, Access quits, ???)?

More specific information will lead to more specific suggestions...

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
I have a form form1 which lauches another popup form form2. form2 has a
number of listboxes with thier row source bound to stored procedures to
populate them. Once the user has selected the company (listbox1), location
(listbox2) and contact (listbox3) I wish to return the selected values to
textboxes in form1.

I can't seem to find the listbox method that gives me the selected value
from the listbox. I am not allowing multiple value selection so should only
need to return a single value.
 
Please re-read my previous response.

A listbox with, say, 4 fields displayed can have 17 fields, with a width of
"0" for all but 4 of them. Typically, the first field is used to hold the
rowID from the underlying source table/query, but its width is set to 0 so
it doesn't show/confuse the user. Typically, the first visible field is the
one that contains the user-friendly text.

You haven't indicated which you are trying to retrieve.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Listbox1 has a single field value that I would like to retrieve and Listbox2
and 3 have multiple fields 2 and 5 respectively. I would only like to
retrive the first selected field for listbox2 and the entire selected row for
listbox3.

Hope this is enough info.
 
I believe I understand what you are saying. I don't know enough yet about
how your listboxes are set up to give you an answer.

Again, are you saying you want the first field THAT IS DISPLAYED in the row
selected, or the first (bound) field in the selected row? These are not the
same.

What are the SQL statements for the source of listbox2 and listbox3?

Which columns are bound in each? What are the field widths in each?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
The combo is bound to a stored procedure but I only wish to obtain the value
of a selected record in the bound field. So for my listboxes an example is
below, listbox1 would return Model2 and Listbox 2 would return Product 3 and
listbox3 would return Product3,Opt1,Data1,Data2,Data3 where the comma
seperation indicate data items bound to seperate field within the stored
procedure.

Listbox1
Model1
Model2 (this is selected item)
Model3
etc...

Listbox2
Model1,Product1
Model1,Product2
Model1,Product3 (this is the selected item)
Model2,Product1
Model2,Product2
etc..

Listbox3
Product3,Opt1,Data1,Data2,Data3 (this is the selected item)
Product3,Opt2,Data1,Data2,Data3
etc...
 
If you don't want to anwer my post then just say so. Surely there must be a
simple method just to return a value from a listbox, just give me a clue what
to look for.
 
ok, I tried playing about with it after reading some other posts and I can
return the value from the first two listboxes by me.listbox1 and me.listbox2
but me.listbox3 only returns the first selected value of the listbox row and
there are five values in that row. Any idea on how to return the other
values?
 
Don't worry about this either I found out how to do it. It was quite simple
don't know why you made such a big deal about it
 
If you felt I wasn't "just giving you the answer", it's because I couldn't.
Actually, I didn't have enough information to offer a meaningful suggestion.

When I asked for the SQL statement behind the listboxes, I wasn't being
disrespectful. I was asking for information that would help diagnose what
was going on.

If your auto mechanic asked you to describe the noise your vehicle was
making (i.e., "why did you bring it in?"), would you be offended and tell
him/her that they were making a big deal?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Now that you've figured it out, you may want to help out any of the other
folks who read the posts looking for a solution to a similar problem. Care
to post your solution?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Back
Top