mattkorguk
Registered User.
- Local time
- Today, 20:37
- Joined
- Jun 26, 2007
- Messages
- 301
Hi All,
I'm building the below query based on a selection made on a form, as I know Access does some interesting things with dates, I already swap the month and day around in the vb if the month field is >12.
This 'appears' to work fine and produces the query below. The issue I'm having is that it's bringing back the correct details. When I chop a section of the query out and paste it into a standard Access query window the dates have swapped round, only for the start date though (01/11/2014 instead of 11/01/2014) This then brings back all records for some reason as the start date is before the end date.
Any suggestion please guys?!
cheers
Matt
I'm building the below query based on a selection made on a form, as I know Access does some interesting things with dates, I already swap the month and day around in the vb if the month field is >12.
This 'appears' to work fine and produces the query below. The issue I'm having is that it's bringing back the correct details. When I chop a section of the query out and paste it into a standard Access query window the dates have swapped round, only for the start date though (01/11/2014 instead of 11/01/2014) This then brings back all records for some reason as the start date is before the end date.
Any suggestion please guys?!
cheers
Matt
Code:
SELECT 'Inadequate justification of why recommended cancelled' AS [Issue Raised], Sum(IIf([TPC0201]='-1',1,0)) AS Sought, Sum(IIf([TPC0201A]='-1',1,0)) AS Material, Sum(IIf([TPC0201B]='-1',1,0)) AS [S/Check], Sum(IIf([TPC0201C]='-1',1,0)) AS [Rec'd], '1' AS SortNo
FROM ProtCIC
INNER JOIN _SR ON ProtCIC.URN = [_SR].URN
WHERE ((([_SR].SR03) Like '*') AND (([_SR].SR04) Like '*') AND (([_SR].SR06) Between #11/01/2014# And #31/01/2014#) AND (([_SR].SR18) Like 'S25' OR ([_SR].SR18)= 'S30'))
UNION SELECT 'Inadequate justification of why recommended retain' AS [Issue Raised], Sum(IIf([TPC0202]='-1',1,0)) AS Sought, Sum(IIf([TPC0202A]='-1',1,0)) AS Material, Sum(IIf([TPC0202B]='-1',1,0)) AS [S/Check], Sum(IIf([TPC0202C]='-1',1,0)) AS [Rec'd], '2' AS SortNo
FROM ProtCIC
INNER JOIN _SR ON ProtCIC.URN = [_SR].URN
WHERE ((([_SR].SR03) Like '*') AND (([_SR].SR04) Like '*') AND (([_SR].SR06) Between #11/01/2014# And #31/01/2014#) AND (([_SR].SR18) Like 'S25' OR ([_SR].SR18)= 'S30'))
UNION SELECT 'New policy recommended & no recommendation on existing' AS [Issue Raised], Sum(IIf([TPC0203]='-1',1,0)) AS Sought, Sum(IIf([TPC0203A]='-1',1,0)) AS Material, Sum(IIf([TPC0203B]='-1',1,0)) AS [S/Check], Sum(IIf([TPC0203C]='-1',1,0)) AS [Rec'd], '3' AS SortNo
FROM ProtCIC
INNER JOIN _SR ON ProtCIC.URN = [_SR].URN
WHERE ((([_SR].SR03) Like '*') AND (([_SR].SR04) Like '*') AND (([_SR].SR06) Between #11/01/2014# And #31/01/2014#) AND (([_SR].SR18) Like 'S25' OR ([_SR].SR18)= 'S30'))
UNION SELECT 'CIC Cancellation process not followed' AS [Issue Raised], Sum(IIf([TPC0204]='-1',1,0)) AS Sought, Sum(IIf([TPC0204A]='-1',1,0)) AS Material, Sum(IIf([TPC0204B]='-1',1,0)) AS [S/Check], Sum(IIf([TPC0204C]='-1',1,0)) AS [Rec'd], '4' AS SortNo
FROM ProtCIC
INNER JOIN _SR ON ProtCIC.URN = [_SR].URN WHERE ((([_SR].SR03) Like '*') AND (([_SR].SR04) Like '*') AND (([_SR].SR06) Between #11/01/2014# And #31/01/2014#) AND (([_SR].SR18) Like 'S25' OR ([_SR].SR18)= 'S30'))
UNION SELECT 'Other' AS [Issue Raised], Sum(IIf([TPC0205]='-1',1,0)) AS Sought, Sum(IIf([TPC0205A]='-1',1,0)) AS Material, Sum(IIf([TPC0205B]='-1',1,0)) AS [S/Check], Sum(IIf([TPC0205C]='-1',1,0)) AS [Rec'd], '5' AS SortNo
FROM ProtCIC
INNER JOIN _SR ON ProtCIC.URN = [_SR].URN WHERE ((([_SR].SR03) Like '*') AND (([_SR].SR04) Like '*') AND (([_SR].SR06) Between #11/01/2014# And #31/01/2014#) AND (([_SR].SR18) Like 'S25' OR ([_SR].SR18)= 'S30'))
ORDER BY 6;