Setting a Variable from a List Box

  • Thread starter Thread starter rallenr
  • Start date Start date
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!
 
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?
 
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];'.
 
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?
 
Back
Top