Drop down list data for query criteria

chathag

Registered User.
Local time
Today, 22:44
Joined
May 22, 2009
Messages
32

I have a drop down menu within a form that lists operators that will be used as criteria for a query.

The list is as follows:

<=100
<90
<80
<70

I have a query with a field called score. Using the expression builder the query looks at the selected value in the drop down list and filters the results based on the dropdown list value.

i.e if <90 is selected from the list the query returns details of all scores less than 90.

When I run the query the following error message is returned:

This expression is typed incorrectly, or it is too complex to be evaluated…..

Some assistance would be appreciated.

Regards

C
 
I could not get the query to work by referencing the form control in the WHERE clause, but I did come up with an alternate way. I created a form based on the table with the scores to be used as a search results form. I then created an unbound form with a combo box with your criteria. I also added a button to that form that tells Access to open the search results form using the selected combo box criteria as a filter. I have attached a database that illustrates what I have done. The code behind the button is the key to getting it to work.
 

Attachments

Hi Thanks for your reply. The example DB you have attached is not recognised by my PC. I have Access 2003 running on this machine.

Could you please reattach.

Thanks

C
 
I suspect your query sql looks something like


Where [????] = <=90

The ='s sign in red is generated by Access in the query and the <=90 in blue is what is being passed to it from the combo, therefore you have goy invalid syntax

David
 
Thanks, that clarifies why my original method did not work. Do you have an alternative solution?

Thanks

C
 
If you want everything to be <= [something], simply put in your query the <= part and in your combo box only the [something] part...
 
You're welcome. Glad we were able to help out.
 

Users who are viewing this thread

Back
Top Bottom