Goos Afternoon,
The following piece off SQL code is used in a Query to ensure that only a single hard copy document is mailed to 2 recipients at one address where an electronic copy is not required(Hence the False statement). The need has now arisen to add an 'OR' function to cause a copy to be sent when an overriding instruction is contained in a 'Notes' field.
Adding the 'OR' function below the 'False' expression produces the following SQL code which is obviously incorrect.
SELECT a.[Member ID], a.[Address 1], a.[Member Name], a.[Address 2], a.Town, a.PostCode, a.[e-News List], a.[e-Mail List]
FROM [Mail List] AS a
GROUP BY a.[Member ID], a.[Address 1], a.[Member Name], a.[Address 2], a.Town, a.PostCode, a.[e-News List], a.[e-Mail List], CStr([a].[Member ID])+[a].[Address 1]
HAVING (((a.[e-News List])=False) AND ((CStr([a].[Member ID])+[a].[Address 1])=(Select cStr(Min(b.[Member ID])) + b.[Address 1]
From [Mail List] as b
Where b.[Address 1] = a.[Address 1]
Group By [Address 1]))) OR ((([Mail List].[Notes])="*XTRANL*"));
Any suggestion to locate the 'Or' function in the correct place would be gratefully received.
Regards,
jcbhydro
The following piece off SQL code is used in a Query to ensure that only a single hard copy document is mailed to 2 recipients at one address where an electronic copy is not required(Hence the False statement). The need has now arisen to add an 'OR' function to cause a copy to be sent when an overriding instruction is contained in a 'Notes' field.
Adding the 'OR' function below the 'False' expression produces the following SQL code which is obviously incorrect.
SELECT a.[Member ID], a.[Address 1], a.[Member Name], a.[Address 2], a.Town, a.PostCode, a.[e-News List], a.[e-Mail List]
FROM [Mail List] AS a
GROUP BY a.[Member ID], a.[Address 1], a.[Member Name], a.[Address 2], a.Town, a.PostCode, a.[e-News List], a.[e-Mail List], CStr([a].[Member ID])+[a].[Address 1]
HAVING (((a.[e-News List])=False) AND ((CStr([a].[Member ID])+[a].[Address 1])=(Select cStr(Min(b.[Member ID])) + b.[Address 1]
From [Mail List] as b
Where b.[Address 1] = a.[Address 1]
Group By [Address 1]))) OR ((([Mail List].[Notes])="*XTRANL*"));
Any suggestion to locate the 'Or' function in the correct place would be gratefully received.
Regards,
jcbhydro