Setting a Variable from a List Box

R

rallenr

Using a list box, I simply need to pass the user's selection from the pull
down (which displays values from a particular column in a table) to a
variable. Stumped.

Is this a Dlookup? An SQL statement? Suggested VBA code appreciated!
 
K

Klatuu

Your question is confusing. You say you are using a list box, put a list box
doesn't have a "pull down". Which is it?

Also, give some detail on the control. For example, how many columns?
Which column do you want to return?
If it is a list box, is it multi select?
 
R

rallenr

A list box on a form is set to display all the field values from a single
column of a three-column table of about a dozen rows. I need to set a
variable equal to the value of the item selected from the list box and then
use in for a DoCmd. You're right -- 'pulldown' is an inaccurate term. The
list box's Row Source Type is 'Table/Query' and the Row Source is 'SELECT
tablename.fieldname FROM tablename ORDER BY [fieldname];'.
 
K

Klatuu

Great, then, assuming it is not a multi select list box it would just be:

strMyVariable = Me.MyListBox

--
Dave Hargis, Microsoft Access MVP


rallenr said:
A list box on a form is set to display all the field values from a single
column of a three-column table of about a dozen rows. I need to set a
variable equal to the value of the item selected from the list box and then
use in for a DoCmd. You're right -- 'pulldown' is an inaccurate term. The
list box's Row Source Type is 'Table/Query' and the Row Source is 'SELECT
tablename.fieldname FROM tablename ORDER BY [fieldname];'.

Klatuu said:
Your question is confusing. You say you are using a list box, put a list box
doesn't have a "pull down". Which is it?

Also, give some detail on the control. For example, how many columns?
Which column do you want to return?
If it is a list box, is it multi select?
 

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