Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can a query have a drop down list?

Status
Not open for further replies.

cdl1701

Technical User
Dec 10, 2004
47
US
I have a couple of queries made where there are a limited possable number of searchable names.. What I would like to be able to do is have the user just select from a list of possable searches when the query is ran.

Thanks for your help =)
 
How about a form with a combobox for the names and then have a query taking the choice from the form and use it as criteria? In your query, on the criteria line underneath the appropriate field, you'd type something like:
[Forms]![Timeline_Input_Form]![mmcid] or in general

[Forms]![FormName]![FormComboBoxName]
Note: The form must remain open. But you can hide it, or minimize it.

After they choose a name, you can have a command button to run the query which will pick up the needed info from the form.
 
Hmmmm that is a good Idea... is there a way to have it automaticly close after the query is finished?
 
Actually I guess that I would have to create a macro that runs the final query and closes the form that I used to select the information for the query after the query is finished?
 
I gave your suggestion a try but for some reason the query is not taking the criteria from the form fields. I will have to give it a try again tonight when I get home.
 
Try

Like "*" & [forms]![nameofform].[nameoftextbox] & "*"

in you query criteria

which will look for matches which are not exact
ie it will find freda and wilfred if you type fred in the textbox.


Ian Mayor (UK)
Program Error
There's ALWAYS more than one way to skin a cat!
But only one way to get it RIGHT!
 
I got everything to work except for the check box items that I have on the search form. How would I get this to work using the check boxes?
 
One more thing the check boxes are in an Option Group if that makes a differance
 
I'm not exactly sure what you're doing. You mean they check a box and that selection becomes criteria for a query?
The following code shows how to use an Option Group selection. Maybe you can figure out what you need.

[RptFrame] is the name of the Option Group
Case 1, 2, 3 are the options in the group in order top to bottom.

Dim WClause, RName
Select Case [RptFrame]
Case 1
WClause = "[DateOfLease] Between #" & _
Me![Start] & "# AND #" & _
Me![End] & "#"
RName = "Sales_And_Leasing_Rpt"

Case 2
WClause = "[FinalSettlementDate]is null"
RName = "Sales_And_Leasing_Rpt"

Case 3
WClause = "[FinalSettlementDate] Between #" & _
Me![Start] & "# AND #" & _
Me![End] & "#"
RName = "Sales_Report"
End Select

DoCmd.OpenReport _
ReportName:=RName, _
WhereCondition:=WClause, _
view:=Me![OutputTo]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top