Hello All
I have a query that runs perfectly. When I copy the SQL code from it into the click event of a button I get a compile error. The SQL is a bit complex but as i said it runs fine in the query.
SQL...
SELECT Demo.PREFIX, Demo.FNAME, Demo.LNAME, Demo.PREFIX2, Demo.FNAME2, Demo.LNAME2, Switch(IsNull([Fname2]),[demo.Prefix] & " " & [Fname] & " " & [Lname],(IsNull([Lname2]) And Not IsNull([Fname2])) Or ([Lname]=[Lname2]),[demo.Prefix] & " & " & [demo.Prefix2] & " " & [Fname] & " " & [Lname],Not IsNull([Lname2]) And [lname]<>[Lname2],[demo.Prefix] & " " & [Fname] & " " & [Lname] & " and " & [demo.Prefix2] & " " & [Fname2] & " " & [Lname2]) AS Greet, Payment.GIFT_TYPE, Demo.STREET1, Demo.STREET2, Demo.CITY, Demo.STATE, Demo.ZIP, Payment.GIFTDATE, [demo.city]+" " & [demo.state]+" " & [demo.zip] AS cityline, Payment.AMOUNT INTO TblAckLetter
FROM Demo INNER JOIN Payment ON Demo.Id = Payment.fkDemoId
WHERE (((Payment.GIFTDATE) Between [StartDate] And [EndDate]));
Any thoughts appreciated.
I have a query that runs perfectly. When I copy the SQL code from it into the click event of a button I get a compile error. The SQL is a bit complex but as i said it runs fine in the query.
SQL...
SELECT Demo.PREFIX, Demo.FNAME, Demo.LNAME, Demo.PREFIX2, Demo.FNAME2, Demo.LNAME2, Switch(IsNull([Fname2]),[demo.Prefix] & " " & [Fname] & " " & [Lname],(IsNull([Lname2]) And Not IsNull([Fname2])) Or ([Lname]=[Lname2]),[demo.Prefix] & " & " & [demo.Prefix2] & " " & [Fname] & " " & [Lname],Not IsNull([Lname2]) And [lname]<>[Lname2],[demo.Prefix] & " " & [Fname] & " " & [Lname] & " and " & [demo.Prefix2] & " " & [Fname2] & " " & [Lname2]) AS Greet, Payment.GIFT_TYPE, Demo.STREET1, Demo.STREET2, Demo.CITY, Demo.STATE, Demo.ZIP, Payment.GIFTDATE, [demo.city]+" " & [demo.state]+" " & [demo.zip] AS cityline, Payment.AMOUNT INTO TblAckLetter
FROM Demo INNER JOIN Payment ON Demo.Id = Payment.fkDemoId
WHERE (((Payment.GIFTDATE) Between [StartDate] And [EndDate]));
Any thoughts appreciated.