Query Based on Combo Box

Lisad

Access Beginner
Local time
Yesterday, 22:04
Joined
Jan 26, 2005
Messages
31
I have a parameter query which is based upon a combo box on a form. When I select something from the combo box the query runs, but I get no records returned. If I run the query without the combo box input (just by typing in the criteria), records are displayed no problem. What am I missing?

This is what I have on my Combo Box.

Private Sub ComboExec_AfterUpdate()
DoCmd.OpenQuery "QRYExecDiary", acReadOnly
End Sub

This is what I have in the criteria in my Exec field in my query.

[forms]![SwitchBoard]![ComboExec]

where SwitchBoard is the name of my form and ComboExec is the name of my combo box.

I also have this as criteria on another field in my query, which I type in. I have removed this from the query and I still get blank records so I don't think it is the problem.

Between [enter start date] And [enter end date]

Any help would be greatly appreciated!
 
If the combo box is a multi-column one, make sure that your bound column is correct for your query.
 
This worked, I had column 1 bound and it was looking for column 2. Thanks very much for your help.
 
What if I still want to keep to 2 column?...
Because its like the combo box has a list of names and the departments those people are related to...
How do I make it so that it searches the name and not the department then?
 
What if I still want to keep to 2 column?...
Because its like the combo box has a list of names and the departments those people are related to...
How do I make it so that it searches the name and not the department then?

If I understand your Question correctly, then:

[forms]![SwitchBoard]![ComboExec].Column(1) should get you Column 1

[forms]![SwitchBoard]![ComboExec].Column(2) should get you Column 2

-- Rookie
 
Then again I set the criteria as LIKE "*" & [Who are you looking for?] & "*"
I tried LIKE "*" & [Who are you looking for?].Column(1) & "*"
but still get an error message though
Help
 
Then again I set the criteria as LIKE "*" & [Who are you looking for?] & "*"
I tried LIKE "*" & [Who are you looking for?].Column(1) & "*"
but still get an error message though
Help
What is "[Who are you looking for?]? Is that the name of a form? It sure doesn't look like it. That is the answer you were given - how to use a FORM to select someone and use that. Not a parameter prompt.

My suggestion is to read this:
http://www.tek-tips.com/faqs.cfm?fid=6763
 
Its a Parameter Query
"Who are you looking for?" is prompted when the user opens the query because I want the user to use the query to search instead of using a Form
 
Its a Parameter Query
"Who are you looking for?" is prompted when the user opens the query because I want the user to use the query to search instead of using a Form
Use a form for input parameters. Did you read the info at the link I gave you as to why parameter prompts are NOT a good idea to use.
 

Users who are viewing this thread

Back
Top Bottom