S
Sheila D
I have a report where the underlying query gets its croteria from a form.
There are 3 selection fields and ifthey are all completed it works fie. I
want to be able to leave 1 or more blank and for those the report returns all
records that match other critria that is selected. My SQL currently looks
like this:
SELECT T_Procedures.Consultant, Format([Date_Of_Procedure],"yyyy") AS
[Year], Format([Date_Of_Procedure],"mm") AS GrpMth,
Format([Date_Of_Procedure],"mmmm") AS [Month], T_Patients.Surname,
T_Patients.Forename, [Forename] & " " & [Surname] AS Name,
T_Procedure_Type.Procedure_Number, T_Procedure_Type.Procedure_Type,
T_Procedures.Hospital_Number, T_Procedures.Date_Of_Procedure
FROM (T_Patients INNER JOIN T_Procedures ON T_Patients.Hospital_Number =
T_Procedures.Hospital_Number) INNER JOIN T_Procedure_Type ON
T_Procedures.Procedure_Number = T_Procedure_Type.Procedure_Number
WHERE (((T_Procedures.Consultant) Like
IIf([Forms]![ChooseF_Consultant_History]![Consultant] Is
Null,"*",[Forms]![ChooseF_Consultant_History]![Consultant])) AND
((T_Procedures.Date_Of_Procedure) Between
[Forms]![ChooseF_Consultant_History]![Start Date] And
[Forms]![ChooseF_Consultant_History]![End Date])) OR
((([Forms]![ChooseF_Consultant_History]![Start Date]) Is Null)) OR
((([Forms]![ChooseF_Consultant_History]![End Date]) Is Null))
GROUP BY T_Procedures.Consultant, Format([Date_Of_Procedure],"yyyy"),
Format([Date_Of_Procedure],"mm"), Format([Date_Of_Procedure],"mmmm"),
T_Patients.Surname, T_Patients.Forename, [Forename] & " " & [Surname],
T_Procedure_Type.Procedure_Number, T_Procedure_Type.Procedure_Type,
T_Procedures.Hospital_Number, T_Procedures.Date_Of_Procedure;
The Consultant part on it's own is fine but I can't get the dates to work in
conjunction with this - any help much appreciated
Sheila
There are 3 selection fields and ifthey are all completed it works fie. I
want to be able to leave 1 or more blank and for those the report returns all
records that match other critria that is selected. My SQL currently looks
like this:
SELECT T_Procedures.Consultant, Format([Date_Of_Procedure],"yyyy") AS
[Year], Format([Date_Of_Procedure],"mm") AS GrpMth,
Format([Date_Of_Procedure],"mmmm") AS [Month], T_Patients.Surname,
T_Patients.Forename, [Forename] & " " & [Surname] AS Name,
T_Procedure_Type.Procedure_Number, T_Procedure_Type.Procedure_Type,
T_Procedures.Hospital_Number, T_Procedures.Date_Of_Procedure
FROM (T_Patients INNER JOIN T_Procedures ON T_Patients.Hospital_Number =
T_Procedures.Hospital_Number) INNER JOIN T_Procedure_Type ON
T_Procedures.Procedure_Number = T_Procedure_Type.Procedure_Number
WHERE (((T_Procedures.Consultant) Like
IIf([Forms]![ChooseF_Consultant_History]![Consultant] Is
Null,"*",[Forms]![ChooseF_Consultant_History]![Consultant])) AND
((T_Procedures.Date_Of_Procedure) Between
[Forms]![ChooseF_Consultant_History]![Start Date] And
[Forms]![ChooseF_Consultant_History]![End Date])) OR
((([Forms]![ChooseF_Consultant_History]![Start Date]) Is Null)) OR
((([Forms]![ChooseF_Consultant_History]![End Date]) Is Null))
GROUP BY T_Procedures.Consultant, Format([Date_Of_Procedure],"yyyy"),
Format([Date_Of_Procedure],"mm"), Format([Date_Of_Procedure],"mmmm"),
T_Patients.Surname, T_Patients.Forename, [Forename] & " " & [Surname],
T_Procedure_Type.Procedure_Number, T_Procedure_Type.Procedure_Type,
T_Procedures.Hospital_Number, T_Procedures.Date_Of_Procedure;
The Consultant part on it's own is fine but I can't get the dates to work in
conjunction with this - any help much appreciated
Sheila