This may be a simple question but I've been hitting my head against the computer screen all day trying to get my query to work.
So, try this...
I have an IIF statement that searches through all the records in my database and keeps a running sum of the instances that a certain value is found in a field (Primary_Procedure). An example is as follows:
SELECT Sum(IIf(([EncounterTable].[Primary_Procedure])="99384" or "99385",1,0)) AS Immunize
FROM EncounterTable;
What is suppose to happen is the query keep a running sum of all the instances that the Primary_Procedure variable = 99384 or 99385 (these are text not numbers because there are some codes in this field that have numbers and letters). What is actually happening is when I just have one criteria specified:
SELECT Sum(IIf(([EncounterTable].[Primary_Procedure])="99384",1,0))
I get the number 3 back, which is correct.
When I try to look for more than one criteria at a time (99384 AND 99385), I get back 19, which is the total number of records in my database (so far). I should really be getting back 5, the total number of records with 99384 or 99385 in the specified field.
What am I doing wrong? How can I search for multiple criteria in this query?
Thanks,
Lis
So, try this...
I have an IIF statement that searches through all the records in my database and keeps a running sum of the instances that a certain value is found in a field (Primary_Procedure). An example is as follows:
SELECT Sum(IIf(([EncounterTable].[Primary_Procedure])="99384" or "99385",1,0)) AS Immunize
FROM EncounterTable;
What is suppose to happen is the query keep a running sum of all the instances that the Primary_Procedure variable = 99384 or 99385 (these are text not numbers because there are some codes in this field that have numbers and letters). What is actually happening is when I just have one criteria specified:
SELECT Sum(IIf(([EncounterTable].[Primary_Procedure])="99384",1,0))
I get the number 3 back, which is correct.
When I try to look for more than one criteria at a time (99384 AND 99385), I get back 19, which is the total number of records in my database (so far). I should really be getting back 5, the total number of records with 99384 or 99385 in the specified field.
What am I doing wrong? How can I search for multiple criteria in this query?
Thanks,
Lis