Fizzio
Chief Torturer
- Local time
- Today, 01:06
- Joined
- Feb 21, 2002
- Messages
- 1,884
I have a reports menu that can churn out reports for several time scales eg months, quarters , calendar year and financial year. I use 2 combo boxes. 1 to select the timescale, 1 to select the year. The timescale combo looks up date values from a lookup table ie StartDate and EndDate. These are formatted dd/MM.
In my query I have the criteria for DateofContact to Between [StartDate] and [EndDate] and the year set to the year combo. I use the same query for all the reports so how do I alter my query so that it can span 2 years eg for financial year queries? The SQL looks like
PARAMETERS [Forms]![ReportsMenu]![cboSelTime] Long;
SELECT DISTINCT PatientInfo.PatientGender, AgeBands.AgeBandDesc, Count(Contacts.ContactID) AS CountOfContactID
FROM TimeScale, ((AgeBands INNER JOIN PatientInfo ON AgeBands.AgeBandID = PatientInfo.AgeBandID) INNER JOIN ReferralInfo ON PatientInfo.PatientID = ReferralInfo.PatientID) INNER JOIN (ContactTypes INNER JOIN Contacts ON ContactTypes.ContactTypeID = Contacts.ContactTypeID) ON ReferralInfo.ReferralID = Contacts.ReferralID
WHERE (((ContactTypes.ContactType)="First In Financial Year") AND ((TimeScale.TimeScaleID)=[Forms]![ReportsMenu]![cboSelTime]) AND ((Contacts.DateOfContact) Between Format([TimeScale]![TimeScaleStart],"dd\/mm") And Format([TimeScale]![TimeScaleEnd],"dd\/mm")) AND ((Format([DateOfContact],"yyyy"))=[Forms]![ReportsMenu]![cboYearSelect]))
GROUP BY PatientInfo.PatientGender, AgeBands.AgeBandDesc;
It works fine for separate months etc but I cannot suss out how to adjust it to be able to handle Q4 and Financial Year??
In my query I have the criteria for DateofContact to Between [StartDate] and [EndDate] and the year set to the year combo. I use the same query for all the reports so how do I alter my query so that it can span 2 years eg for financial year queries? The SQL looks like
PARAMETERS [Forms]![ReportsMenu]![cboSelTime] Long;
SELECT DISTINCT PatientInfo.PatientGender, AgeBands.AgeBandDesc, Count(Contacts.ContactID) AS CountOfContactID
FROM TimeScale, ((AgeBands INNER JOIN PatientInfo ON AgeBands.AgeBandID = PatientInfo.AgeBandID) INNER JOIN ReferralInfo ON PatientInfo.PatientID = ReferralInfo.PatientID) INNER JOIN (ContactTypes INNER JOIN Contacts ON ContactTypes.ContactTypeID = Contacts.ContactTypeID) ON ReferralInfo.ReferralID = Contacts.ReferralID
WHERE (((ContactTypes.ContactType)="First In Financial Year") AND ((TimeScale.TimeScaleID)=[Forms]![ReportsMenu]![cboSelTime]) AND ((Contacts.DateOfContact) Between Format([TimeScale]![TimeScaleStart],"dd\/mm") And Format([TimeScale]![TimeScaleEnd],"dd\/mm")) AND ((Format([DateOfContact],"yyyy"))=[Forms]![ReportsMenu]![cboYearSelect]))
GROUP BY PatientInfo.PatientGender, AgeBands.AgeBandDesc;
It works fine for separate months etc but I cannot suss out how to adjust it to be able to handle Q4 and Financial Year??