Error in SQL concatenation
I have built the followign code :
Dim SQLCustomerOrder As String
Dim SQLAfid As String
Dim SQLBas As String
SQLAfid = “AND ((Customers.afid)=1)”
SQLBas = ” SELECT DISTINCT Customers.*, orders.paymentid, Customers.afid FROM Customers INNER JOIN orders ON (Customers.Customerid = orders.customerid) AND (Customers.Customerid = orders.customerid) WHERE (((orders.paymentid)=0) );”
SQLCustomerOrder = SQLBas & SQLAfid
Me.RecordSource = SQLCustomerOrder
i have tried to divide a valid sql clasue into two parts, but i failed to do it
and i receive the meesage “Characters found after end of sql clause”.
The original and valid sql query was as follows
SELECT DISTINCT Customers.*, orders.paymentid, Customers.afid
FROM Customers INNER JOIN orders ON (Customers.Customerid = orders.customerid) AND (Customers.Customerid = orders.customerid)
WHERE (((orders.paymentid)=0) AND ((Customers.afid)=1));
It seems i cannot take out the And clause in the rigth way.
ANy help?