Query Issue

Flora2021

New Member
Joined
Apr 28, 2022
Messages
44
Office Version
  1. 365
Platform
  1. Windows
Hi, I have a query that I am trying to use criteria from two columns.
The one is "type" and the other is "status"

I have entered the type as a criteria such as "RO"
For the status column, I wanted this to be variable for the user to enter the status such as Open, closed, in process etc.
Basically it would return all records where the type is "RO" and the status would be whatever the user enters in the prompt".
Well the issue I am having is that if we actually enter the status of say Open, then the query is pulling all open records, but its pulling for all types, such as RO, Claims, Dmages, etc. Its no longer filtering on the type in entred in the criteria. However if I leave the status blank, it only pulls the "RO" criteria. I also just tried removing the "enter status or leave blank" prompt and entered the Open, In process, on hold status in the criteria and the OR fields and its doing the exact same thing. I am sure this is something similar i am doing wrong so I would appreciate any help. Thanks:)
1656528703860.png
 

Attachments

  • query_12.PNG
    query_12.PNG
    8.1 KB · Views: 3
  • query 12.PNG
    query 12.PNG
    7.7 KB · Views: 4
  • query12_1.PNG
    query12_1.PNG
    4.7 KB · Views: 4
  • query_12_2.PNG
    query_12_2.PNG
    6.1 KB · Views: 4

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
That is because are entering the criteria on TWO criteria lines instead of one.
Note that on the far left, under the word "Criteria" is the word "Or". This means if you use multiple criteria lines, it will treat it as an "OR" situation, and it sounds like you want an "AND" situation.
So you would need to put the Criteria for the different fields on the SAME Criteria row (the first one), to treat it like an "AND" situation.
 
Upvote 0
That is because are entering the criteria on TWO criteria lines instead of one.
Note that on the far left, under the word "Criteria" is the word "Or". This means if you use multiple criteria lines, it will treat it as an "OR" situation, and it sounds like you want an "AND" situation.
So you would need to put the Criteria for the different fields on the SAME Criteria row (the first one), to treat it like an "AND" situation.
Thank you. I am confused. How would I enter this? Just to clarify, My criteria in first column says "RO" for Risk and Opportunity. Not OR. Thanks,
 
Upvote 0
Just Move the parameter under the "Status" field of "[Enter a status, leave blank to show all]" up one line so it is on the SAME criteria row as the "RO" Criteria under the "Type" field.
And totally delete the other field next to it that I show crossed out below:

1656674807165.png

Remember:
- Criteria listed on the SAME Criteria row are treated as AND
- Criteria listed on SEPARATE Criteria rows are teated as OR
 

Attachments

  • 1656674800746.png
    1656674800746.png
    17.7 KB · Views: 3
Upvote 0
Thank you :) So the first part is working now where it is pulling the correct records, when i enter a status, but when i leave blank it shows no records.
 
Upvote 0
I am not in front of a computer with Access right now, so I am doing this off of memory, but I think maybe you can change that parrmeter to something like this:
Rich (BB code):
Like [Enter a status, leave blank to show all] & "*"

See if that works.

If not, I am guessing that you got your original structure from this link here: Return All Records using Query Parameters | Database Solutions for Microsoft Access | databasedev.co.uk
Try going back to that strucutre, and try adding the "RO" Criteria under the "Type" field under BOTH Criteria rows being used.
 
Upvote 0
Solution
You are welcome.
Out of curiosity, which method did you go with?
 
Upvote 0
Like [Enter a status, leave blank to show all] & "*" :)
Excellent!
I was doing that off of memory (hadn't done that in a few years). So it is good to know that the old gray matter still works (once in a while!).
 
Upvote 0

Forum statistics

Threads
1,215,420
Messages
6,124,801
Members
449,189
Latest member
kristinh

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