WT: Advanced Filtering Example
The AND condition is always checked first. If a table has 2 fields that need checked, the criteria for each field must be met. If any one criteria is not met, the record is excluded.
If a filter has OR, it will be second to check.
The criteria are applied as a set, and only records that match any of the criteria in the Criteria row are displayed. To specify alternate criteria for a single field, type the first criterion in the Criteria row and the second criterion in the Or row, and so on. If none of the criteria is met, the record is excluded.
Scenario
In an ongoing effort to improve customer relations, your company has decided to assign a Sales Representative/Account Manager to each of your Customers. You will be hiring a Sales Rep to cover some of these accounts.
You will roll this out quarterly, starting with your home state of Nebraska.
You will be using Advanced Filtering from the Customer Master File to find out this information.
The CustomerNumber field defaults to the grid since this is the Primary Key related to the tblAR_Customers.
No Criteria is added for the CustomerNumber.
You selected the "State" field and your criteria list displays options applicable to the field's data type.
For the "State" field, your criteria list looks like this:
You want to take a look at just Nebraska, so you select Equal.
Enter the value of NE for Nebraska.
You also want to know which Customers in NE do not have a Sales Rep assigned to them.
Add the "SalesmanID", and select "Is Blank" for the criteria.
Your results indicate that you have 6 Customers in Nebraska who do not have a Salesman assigned to them.
You think your Sales Rep can handle more than these 6 Customers. So you have decided to add Minnesota to his load.
You added a second criteria for "Equals" "MN".
Your results are not quite what you intended.
The results have given you "exactly" what you asked for, but not what you intended.
The results give you
- Customers in Nebraska with no Sales Rep assigned
AND
- Customers in Minnesota
Remember AND is always first. The Criteria for each field must be met. If a filter has OR, it will be second to check.
What you really want is
- Customers in Nebraska with no Sales Rep assigned
AND
- Customers in Minnesota with no Sales Rep assigned
Let's change your Filters.
These are the intended results.
You have 10 Customers in Nebraska and Minnesota with no Sales Rep assigned.
It may make more sense to change the Sort Order to sort By State, rather than by Customer Number.
So let's change the filter Sort Order.
Your results are what you want.
If you click back on the Filter tab, and then click Apply filter, your recordset will load the 10 records. Then you can assign the new Sales Rep to those Customer Master File records.
Taking a closer look at filter, you can see how the results were derived.
So basically the Criteria that is met in are the first set of records that added to the Results grid.
Then records that meet the Criteria in are then added to the Results grid.
So you are really looking at 2 sets of filters.