Sql code that runs fine in access
SELECT L.ClientID as client_num, L.LoanNumberID as loan_num FROM (tblLoan AS L INNER JOIN tblADP as A on (A.ClientID = L.ClientID AND A.LoanNumberID = L.LoanNumberID)) LEFT OUTER JOIN tblFeeResults as R on R.ClientID = L.ClientID AND R.LoanNumberID = L.LoanNumberID WHERE FeeProtectionStartDate IS NOT NULL AND FeeProtectionEndDate IS NOT NULL AND L.BatchCheckReportDate IS NULL AND R.LoanNumberID IS NULL AND R.ClientID IS NULL AND A.BatchNumber Like '2.1*' AND ((L.AcquisitionID IN ('5261009WAA','5261009WAB')) OR (Len(L.AcquisitionID) <= 6) OR (L.AcquisitionID IS NULL)) GROUP BY L.ClientID, L.LoanNumberID;
Take out AND A.BatchNumber Like '2.1*' and it runs in vb.
vbcode building query
"SELECT L.ClientID as client_num, L.LoanNumberID as loan_num " & _
"FROM (tblLoan AS L " & _
"INNER JOIN tblADP as A on (A.ClientID = L.ClientID AND A.LoanNumberID = L.LoanNumberID)) " & _
"LEFT OUTER JOIN " & RESULT_TABLE & " as R on R.ClientID = L.ClientID AND R.LoanNumberID = L.LoanNumberID " & _
"WHERE FeeProtectionStartDate IS NOT NULL " & _
"AND FeeProtectionEndDate IS NOT NULL " & _
"AND L.BatchCheckReportDate IS NULL " & _
"AND R.LoanNumberID IS NULL " & _
"AND R.ClientID IS NULL " & _
"AND A.BatchNumber Like '2.1*' " & _
"AND ((L.AcquisitionID IN ('5261009WAA','5261009WAB')) OR (Len(L.AcquisitionID) <= 6) OR (L.AcquisitionID IS NULL)) " & _
"GROUP BY L.ClientID, L.LoanNumberID;"
|