[RESOLVED] Excel - ADODB and not returning data
Hi,
Haven't used Excel in a while to do this, but am fixing/adding to some older code.
I have a query that joins to two tables. When run in Access (and the % changed to *) it runs. In the VBA coding, it runs (no error) but doesn't return the matching fields in the linked table.
Any ideas what I'm doing wrong?
Code:
strSql = "SELECT" & vbCrLf
strSql = strSql & " 'Jag' as Brand, AL.Mondial_Ref, AL.Registration_Number" & vbCrLf
strSql = strSql & " , AL.Customer_Name, AL.Dealer_Code" & vbCrLf
strSql = strSql & " , AL.Chassis_Number, AL.ReasonCode" & vbCrLf
strSql = strSql & " , tblDFredRefs.FREDRef, TB_CDSI.Full_Name, tblDFredRefs.ConfirmedValidOn" & vbCrLf
strSql = strSql & " FROM (TBL_Mondial_ActiveList as AL" & vbCrLf
strSql = strSql & " LEFT JOIN tblDFredRefs ON AL.Mondial_Ref = tblDFredRefs.CHRef" & vbCrLf
strSql = strSql & " ) LEFT JOIN TB_CDSI ON tblDFredRefs.ConfirmedValidBy = TB_CDSI.UserID" & vbCrLf
strSql = strSql & " WHERE AL.ReasonCode Like 'FRED%'" & vbCrLf
strSql = strSql & " UNION ALL" & vbCrLf
strSql = strSql & " SELECT " & vbCrLf
strSql = strSql & " 'LR' as Brand, AL.Mondial_Ref, AL.Registration_Number" & vbCrLf
strSql = strSql & " , AL.Customer_Name, AL.Dealer_Code" & vbCrLf
strSql = strSql & " , AL.Chassis_Number, AL.ReasonCode" & vbCrLf
strSql = strSql & " , tblDFredRefs.FREDRef, TB_CDSI.Full_Name, tblDFredRefs.ConfirmedValidOn" & vbCrLf
strSql = strSql & " FROM (TBL_Mondial_ActiveList1 as AL" & vbCrLf
strSql = strSql & " LEFT JOIN tblDFredRefs ON AL.Mondial_Ref = tblDFredRefs.CHRef" & vbCrLf
strSql = strSql & " ) LEFT JOIN TB_CDSI ON tblDFredRefs.ConfirmedValidBy = TB_CDSI.UserID" & vbCrLf
strSql = strSql & " WHERE AL.ReasonCode Like 'FRED%'" & vbCrLf
To me it looks fine and it isn't erroring, which is weird. Its just not working.
Re: [RESOLVED] Excel - ADODB and not returning data
Abosolutely nothing wrong... except the data - which is not what I thought it was...
Feels like a monday