How to give users a list box when running a query

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

Guest

I'd like to set up a query which gives users a list of items to choose from
when running a query - The chosen item should then be the criteria for that
field. The list should come from another table which contains that field as
unique entries Anyone able to help me out?

Thanks in advance
 
Dear Ian:

There is no facility for doing this, except to create a form, put the list
box on that form, and reference that control from the query. For this to
work, the form must be open and the list box must have a selection made.

If you intend to allow for only a single row to be selected, may I recommend
a combo box instead.

If you intend to allow mulitple selections, which only a list box allows,
then some programming is in order.

Referencing a single valued control (not a multi-select list box, but a
single select list box or combo box) is done using this syntax in the query,
where you might otherwise place a literal value for the control:

[Forms]![Form Name]![Control Name]

Replace Form Name with the actual name of your form, and ControlName with
the actual name of your control.

Tom Ellison
 
create a form and add a list box control to it. set the RowSource of the
list box control to the table that has the unique entries you want to choose
from.

in the query, set the field's criteria as

Forms!FormName!ListBoxName

substituting the correct form name and list box control name, of course.

hth
 
Hi Tom,

What should I do if I need to do the same thing with mutiple selections in a
list box?
Any good resource on the Web I can look this up? I'm not that familiar with
coding so I really need specific instructions.

Thanks
KF

Tom Ellison said:
Dear Ian:

There is no facility for doing this, except to create a form, put the list
box on that form, and reference that control from the query. For this to
work, the form must be open and the list box must have a selection made.

If you intend to allow for only a single row to be selected, may I recommend
a combo box instead.

If you intend to allow mulitple selections, which only a list box allows,
then some programming is in order.

Referencing a single valued control (not a multi-select list box, but a
single select list box or combo box) is done using this syntax in the query,
where you might otherwise place a literal value for the control:

[Forms]![Form Name]![Control Name]

Replace Form Name with the actual name of your form, and ControlName with
the actual name of your control.

Tom Ellison


Ian King said:
I'd like to set up a query which gives users a list of items to choose
from
when running a query - The chosen item should then be the criteria for
that
field. The list should come from another table which contains that field
as
unique entries Anyone able to help me out?

Thanks in advance
 
PMFBI

Helen Feddema wrote an excellent article for WoodysAccessWatch on

Paired MultiSelect Listboxes.

Windows and Access use them alot and they are "kind" to the user.

The listbox on the left presents "Available" items.
The listbox on the right shows "Selected" items.

The user selects one or more items in a listbox, then clicks on "arrow"
command buttons between the lists to move from Available to Selected
(or vica versa)

Search for Vol 2, No.22 on the following site:
http://www.woodyswatch.com/access/archives.asp

or "Access Archon Column #72"

Behind the scenes you have two tables (tblAvailableItems and
tblSelectedItems).
The two listboxes are bound to these two tables.

When you load your "Select" form that the two listboxes are on,
you empty the the two tables
and then assign "available field values" to tblAvailableItems.

Your query then only needs to join to "tblSelectedItems"
once user has "moved" desired items to selected listbox.

Hi Tom,

What should I do if I need to do the same thing with mutiple selections in a
list box?
Any good resource on the Web I can look this up? I'm not that familiar with
coding so I really need specific instructions.

Thanks
KF

Tom Ellison said:
Dear Ian:

There is no facility for doing this, except to create a form, put the list
box on that form, and reference that control from the query. For this to
work, the form must be open and the list box must have a selection made.

If you intend to allow for only a single row to be selected, may I recommend
a combo box instead.

If you intend to allow mulitple selections, which only a list box allows,
then some programming is in order.

Referencing a single valued control (not a multi-select list box, but a
single select list box or combo box) is done using this syntax in the query,
where you might otherwise place a literal value for the control:

[Forms]![Form Name]![Control Name]

Replace Form Name with the actual name of your form, and ControlName with
the actual name of your control.

Tom Ellison


Ian King said:
I'd like to set up a query which gives users a list of items to choose
from
when running a query - The chosen item should then be the criteria for
that
field. The list should come from another table which contains that field
as
unique entries Anyone able to help me out?

Thanks in advance
 
Back
Top