Drop down menu in Query

D

dvgrhl

I hope this makes sense:

I need to have a query that allows the user to define a criteria from a
list, rather than an input box. Currently, tbl_Building has entries
stored in it that I want to be able to select from a list for this
query. For sake of the example, let's call them Building A, Building
B, and Building C.

I have this query set to run and return results between the dates the
user inputs, then by the building inputed, but I need the variable
"Building Name" to be a list from the tbl_Building rather than an input
box where the user has to know exactly the names of the buildings.

SELECT tbl_Work_Order_Info.Building, tbl_Work_Order_Info.Initial_Date,
tbl_Work_Order_Info.[Date Project Started],
=DATEDIFF("d",tbl_Work_Order_Info.Initial_Date,tbl_Work_Order_Info.[Date
Project Started]) AS Expr1, tbl_Work_Order_Info.[Date Project
Completed], =DATEDIFF("d",tbl_Work_Order_Info.[Date Project
Started],tbl_Work_Order_Info.[Date Project Completed]) AS Expr2,
=DATEDIFF("d",tbl_Work_Order_Info.Initial_Date,tbl_Work_Order_Info.[Date
Project Completed]) AS Expr3
FROM tbl_Work_Order_Info
WHERE ((tbl_Work_Order_Info.Initial_Date)>=[Start Date]) And
((tbl_Work_Order_Info.Initial_Date)<=[End Date]) And
((tbl_Work_Order_Info.Building)=[Building Name])
ORDER BY tbl_Work_Order_Info.Building,
tbl_Work_Order_Info.Initial_Date;

Any ideas how to accomplish this? Thanks.
 
W

Walter Steadman

If you are using a form, you can put a combo box with the selections of
building names and then in your query under building name you can put
[Forms]![YourFormName]![YourComboBoxName]
then put a command button that executes the query and that should do the
trick.
 
Top