|
-
Apr 5th, 2011, 06:02 AM
#1
Thread Starter
Don't Panic!
[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.
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Apr 5th, 2011, 10:06 AM
#2
Thread Starter
Don't Panic!
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
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|