Parameter Query Criteria Syntax Issue

debbieR

New Member
Joined
Sep 2, 2017
Messages
8
Hi! This should be simple, but I'm an Access/Query newbie and can't figure out syntax to accomplish the following:
How would I change the criteria syntax to make it return ALL records with value >0 if they just click OK and don't enter a specific value?

PRICE SELL QTY (Parameter Query so it asks them for a value or they click OK to return all values) Current criteria used is:
Like "*" & [Enter QTY or Click OK to Display ALL ] & "*"

This works correctly EXCEPT I need to add "something" to the criteria code that it returns ALL records >0 as well as prompting for a value.
(it doesn't work to just put >0 unless I'm putting it in the wrong place)
Thank you!
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
I think you can use OR
something like
PRICE SELL QTY Like "*" & [Enter QTY or Click OK to Display ALL ] & "*" OR >0

not sure of the Access syntax
 
Upvote 0
Solved it!
Changed to: >0 Or [Enter QTY or Click OK to Display ALL ]
now if they don't enter a value and just click OK, all records with values > 0 are returned.
 
Upvote 0
My Bad...THIS one fixes the "zero" issue if they just click OK AND still displays the correct records if they enter a number:
>0 And Like "*" & [Enter QTY or Click OK to Display ALL ] & "*"
 
Upvote 0
The * wildcard can only be used with text and it seems your field is numeric. Is that the case, or are you treating numbers as text? This may be a candidate for the IIF function. However, regardless if the field is numeric I don't think you can solve this in a query because I don't think you can use > in either the truepart or falsepart of IIF.
In that case, I think your query would need to call a function.
 
Upvote 0
I think you can use OR
something like
PRICE SELL QTY Like "*" & [Enter QTY or Click OK to Display ALL ] & "*" OR >0

not sure of the Access syntax

Thank you...you were very close. I had tried it on the back side and it didn't work (and it needed to be an AND not an OR). This is what worked:
>0 And Like "*" & [Enter QTY or Click OK to Display ALL ] & "*"
 
Upvote 0
That is cool. Sometimes I can't see the forest for the trees :(.
Greater than zero and Like "*"
if no response.
BTW, the first * isn't needed. You're getting ** for no response when all you need is *, which means I stand corrected. You can use * on numbers.
This also works >0 And Like [Enter QTY or Click OK to Display ALL ] & "*"
 
Upvote 0
The * wildcard can only be used with text and it seems your field is numeric. Is that the case, or are you treating numbers as text? This may be a candidate for the IIF function. However, regardless if the field is numeric I don't think you can solve this in a query because I don't think you can use > in either the truepart or falsepart of IIF.
In that case, I think your query would need to call a function.

it is a number field...and I did solve it, see below. Now returns exactly what I was looking for! Thank you for responding though! It took me lots of try's to get it to work so had I not your suggestion may have come in handy.
 
Upvote 0

Forum statistics

Threads
1,214,813
Messages
6,121,706
Members
449,049
Latest member
THMarana

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top