Joe, I think your bracketing is not give you what you intended.
You have asked for the records where first_attendance is between the
dates
and treatment_provided_1 is the boots, plus all the records where
treatment_provided_2, 3, or 4 is the boots regardless of the date.
Is this what you meant?
PARAMETERS [Enter Start Date:] DateTime, [Enter End Date:] DateTime;
SELECT [Patient Treatments Table].mb_service_number,
[Patient Treatments Table].mb_surname,
[Patient Treatments Table].mb_given_names,
[Patient Treatments Table].body_part,
[Patient Treatments Table].diagnosis,
[Patient Treatments Table].history,
[Patient Treatments Table].first_attendance,
[Patient Treatments Table].treatment_provided_1,
[Patient Treatments Table].treatment_provided_2,
[Patient Treatments Table].treatment_provided_3,
[Patient Treatments Table].treatment_provided_4
FROM [Patient Treatments Table]
GROUP BY [Patient Treatments Table].mb_service_number,
[Patient Treatments Table].mb_surname,
[Patient Treatments Table].mb_given_names,
[Patient Treatments Table].body_part,
[Patient Treatments Table].diagnosis,
[Patient Treatments Table].history,
[Patient Treatments Table].first_attendance,
[Patient Treatments Table].treatment_provided_1,
[Patient Treatments Table].treatment_provided_2,
[Patient Treatments Table].treatment_provided_3,
[Patient Treatments Table].treatment_provided_4
HAVING ([Patient Treatments Table].first_attendance
Between [Enter Start Date:] And [Enter End Date:])
AND (([Patient Treatments Table].treatment_provided_1
IN ("boots", "lace-up boots"))
OR ([Patient Treatments Table].treatment_provided_1
IN ("boots", "lace-up boots"))
OR ([Patient Treatments Table].treatment_provided_1
IN ("boots", "lace-up boots"))
OR ([Patient Treatments Table].treatment_provided_1
IN ("boots", "lace-up boots")))
ORDER BY [Patient Treatments Table].mb_service_number,
[Patient Treatments Table].body_part,
[Patient Treatments Table].diagnosis;
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Reply to group, rather than allenbrowne at mvps dot org.
Thanks Allen for your help -
I have declared the two parameters and checked out the article you have
recommended. I have checked the format at table level and field level
(on
the input subform) and all are set at medium date with input in
dd/mm/yy
format. On running my query I still get erroneous data return
regardless
of
the format of data entry (ie dd/mm/yy or dd-mmm-yy etc).
Here is the SQL for the whole query - perhaps you might be able to see
something I'm missing.
PARAMETERS [Enter Start Date:] DateTime, [Enter End Date:] DateTime;
SELECT [Patient Treatments Table].mb_service_number, [Patient
Treatments
Table].mb_surname, [Patient Treatments Table].mb_given_names, [Patient
Treatments Table].body_part, [Patient Treatments Table].diagnosis,
[Patient
Treatments Table].history, [Patient Treatments Table].first_attendance,
[Patient Treatments Table].treatment_provided_1, [Patient Treatments
Table].treatment_provided_2, [Patient Treatments
Table].treatment_provided_3,
[Patient Treatments Table].treatment_provided_4
FROM [Patient Treatments Table]
GROUP BY [Patient Treatments Table].mb_service_number, [Patient
Treatments
Table].mb_surname, [Patient Treatments Table].mb_given_names, [Patient
Treatments Table].body_part, [Patient Treatments Table].diagnosis,
[Patient
Treatments Table].history, [Patient Treatments Table].first_attendance,
[Patient Treatments Table].treatment_provided_1, [Patient Treatments
Table].treatment_provided_2, [Patient Treatments
Table].treatment_provided_3,
[Patient Treatments Table].treatment_provided_4
HAVING ((([Patient Treatments Table].first_attendance) Between [Enter
Start
Date:] And [Enter End Date:]) AND (([Patient Treatments
Table].treatment_provided_1)="boots" Or ([Patient Treatments
Table].treatment_provided_1)="lace-up boots")) OR ((([Patient
Treatments
Table].treatment_provided_2)="boots")) OR ((([Patient Treatments
Table].treatment_provided_2)="lace-up boots")) OR ((([Patient
Treatments
Table].treatment_provided_3)="boots")) OR ((([Patient Treatments
Table].treatment_provided_3)="lace-up boots")) OR ((([Patient
Treatments
Table].treatment_provided_4)="boots")) OR ((([Patient Treatments
Table].treatment_provided_4)="lace-up boots"))
ORDER BY [Patient Treatments Table].mb_service_number, [Patient
Treatments
Table].body_part, [Patient Treatments Table].diagnosis;
The query is attempting to determine how often a specific item of
equipment
was provided during treatment in a specific time period. Treatments are
recorded in 4 separate fields to allow for multiple treatment types to
ensure
standardisation of data input.
Hope you can help.
:
In query design view, choose Parameters from the Query menu, and
declare
two
parameters of type Date/Time:
[Enter Start Date:] Date/Time
[Enter End Date:] Date/Time
This ensures Access knows what type these parameters are, does not
accept
invalid entries, and helps it interpret them correctly.
Since you use d/m/y formatting, this article explains 3 cases where
Access
tends to misunderstand our dates:
International Dates in Access
at:
http://allenbrowne.com/ser-36.html
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Reply to group, rather than allenbrowne at mvps dot org.
In a simple query on a data table (design view) a Between[Enter
Start
Date:]
And [Enter End Date:] is placed on the criteria line of the field
"first_attendance" which is formatted in medium date form. When the
query
is
run with for example Start Date entered as 01/01/01 and End date as
30/12/02
it returns data with "first_attendance" dates in the years 2000,
2002,
2003,
2005 as well as the required year of 2001. What am I doing wrong?