Query Drop Down

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

Guest

I have a query setup that has [Brakets] around employee name so when you run
the query you get prompted to put in an employee name.
Is there a way to create a drop down so instead or typing in the name you
could just choose a name from the drop down?

Thanks
 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Yes. Create a form. Put a ComboBox on the form w/ the RowSourceType =
Query/Table and the RowSource = the employee table name (or a query that
selects the employee_id and the employee_name). Put a CommandButton on
the form. Set the CommandButton's OnClick event to run the query. Have
a Parameter in the query that reads the selected Employee ID from the
ComboBox on the form:

PARAMETERS Forms!FormName!ComboBoxName Integer

SELECT ...
FROM ...
WHERE EmployeeID = Forms!FormName!ComboBoxName

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQ9gAkoechKqOuFEgEQKHnACdFyNrRiWCEl/KfgqvVsTQ0N5+0WAAn0++
STnFarWV8/30s+IpjnZg1Msm
=xVdO
-----END PGP SIGNATURE-----
 
I have a query setup that has [Brakets] around employee name so when you run
the query you get prompted to put in an employee name.
Is there a way to create a drop down so instead or typing in the name you
could just choose a name from the drop down?

Thanks

Yes. Create a little unbound form, let's call it frmCrit; put a combo
box (cboEmployee) on it with the unique EmployeeID as its bound column
(don't use names, they're not unique!)

Use a criterion on your query like

=[Forms]![frmCrit]![cboEmployee]

Base a Form (for onscreen viewing) and/or a Report (for printing) on
the query, and put a command button on frmCrit to open it.

John W. Vinson[MVP]
 
I'll give these a shot. Thanks.

John Vinson said:
I have a query setup that has [Brakets] around employee name so when you run
the query you get prompted to put in an employee name.
Is there a way to create a drop down so instead or typing in the name you
could just choose a name from the drop down?

Thanks

Yes. Create a little unbound form, let's call it frmCrit; put a combo
box (cboEmployee) on it with the unique EmployeeID as its bound column
(don't use names, they're not unique!)

Use a criterion on your query like

=[Forms]![frmCrit]![cboEmployee]

Base a Form (for onscreen viewing) and/or a Report (for printing) on
the query, and put a command button on frmCrit to open it.

John W. Vinson[MVP]
 
Back
Top