I'm creating a report for an imaginary "medical clinic's database" as part of a university assignment and need help with a specific formula, the intended function of which is described as follows: "Create a statistic that shows the total number of distinct drugs prescribed to a patient."
Where I'm at:
I've created a query called UniqueDrugs containing drug and patient info. The SQL is:
I've created a report and I've put the following formula into a text box:
However, this *always* results in #Error, no matter how I change the formula.
I have been led to believe that syntax is not the issue, as the following formula worked as intended for a different task:
How do I use a DCount to return the number of different drugs that have been prescribed to a patient?
If it did not require the number of different drugs, I would simply use the following formula, which works just fine:
Where I'm at:
I've created a query called UniqueDrugs containing drug and patient info. The SQL is:
The results of this query seem to be what I need. All I need is for the count formula that I use to return the number of distinct drug names there are that are related to a patient's ID.SELECT DISTINCT Drugs.Drug_Name, Patients.[Patient _ID]
FROM Patients INNER JOIN (Drugs INNER JOIN Prescriptions ON Drugs.[Drug_ID] = Prescriptions.[Drug_ID]) ON Patients.[Patient _ID] = Prescriptions.[Patient_ID]
GROUP BY Drugs.Drug_Name, Patients.[Patient _ID]
ORDER BY Patients.[Patient _ID];
I've created a report and I've put the following formula into a text box:
Where PID is the name of another text box in the report that contains the Patient ID that I want to compare to the drug names returned by the query.=DCount("[Drug_Name]","[UniqueDrugs]","[Patient_ID]=[PID]")
However, this *always* results in #Error, no matter how I change the formula.
I have been led to believe that syntax is not the issue, as the following formula worked as intended for a different task:
So, my question:=DCount("[Prescription_Date]","[UniqueYearQuery]","[Patient_ID]=[PID]")
How do I use a DCount to return the number of different drugs that have been prescribed to a patient?
If it did not require the number of different drugs, I would simply use the following formula, which works just fine:
Any help would be appreciated and I can provide clarification if needed.=Count(Drug_Name)