livetolearn4life
New Member
- Joined
- Jul 14, 2020
- Messages
- 15
- Office Version
- 2019
- 2016
- 2013
- Platform
- Windows
Hello,
i'm getting sql syntax error trying to return data from external data base. any assistance in figuring out what im doing wrong would be greatly appreciated!
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:= _
"ODBC;DSN=WEDRPGNR1;UID=CDL;PWD=sAB2021", Destination:=Range("$A1")).QueryTable
.CommandText = Array( _
"SELECT DRAWMTWO.RECSEQ, DRAWMTWO.TOOLNO, DRAWMTWO.PARTNAME, DRAWMTWO.TOOLCPRE, DRAWMTWO.TOOLCODEB, DRAWMTWO.TOOLCPST, DRAWMTWO.TWOLOC, DRAWMTWO.SHOP, " _
, "DRAWMTWO.JOBNO, DRAWMTWO.TJOBNO, DRAWMTWO.DATEI, DRAWMTWO.BPREV, DRAWMTWO.REQUESTER, " _
, "WQMSTWOWCM.COMMENT" & Chr(13) & "" & Chr(10) & "FROM {oj S1099F6P.WEBPRDDT1.DRAWMTWO DRAWMTWO LEFT OUTER JOIN S1099F6P.WEBPRDDT1.WQMSTWOWCM WQMSTWOWCM, " _
, "ON DRAWMTWO.RECSEQ= WQMSTWOWCM.TWOINDX}" & Chr(13) & "" & Chr(10) & "WHERE,(DRAWMTWO.SHOP In (0,3,8,9)) AND (DRAWMTWO.TWOLOC<>'Closed'), " _
, "ORDER BY DRAWMTWO.DATEI DESC " _
)
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.ListObject.DisplayName = "Table_ExternalData_1"
.Refresh BackgroundQuery:=False
End With
i'm getting sql syntax error trying to return data from external data base. any assistance in figuring out what im doing wrong would be greatly appreciated!
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:= _
"ODBC;DSN=WEDRPGNR1;UID=CDL;PWD=sAB2021", Destination:=Range("$A1")).QueryTable
.CommandText = Array( _
"SELECT DRAWMTWO.RECSEQ, DRAWMTWO.TOOLNO, DRAWMTWO.PARTNAME, DRAWMTWO.TOOLCPRE, DRAWMTWO.TOOLCODEB, DRAWMTWO.TOOLCPST, DRAWMTWO.TWOLOC, DRAWMTWO.SHOP, " _
, "DRAWMTWO.JOBNO, DRAWMTWO.TJOBNO, DRAWMTWO.DATEI, DRAWMTWO.BPREV, DRAWMTWO.REQUESTER, " _
, "WQMSTWOWCM.COMMENT" & Chr(13) & "" & Chr(10) & "FROM {oj S1099F6P.WEBPRDDT1.DRAWMTWO DRAWMTWO LEFT OUTER JOIN S1099F6P.WEBPRDDT1.WQMSTWOWCM WQMSTWOWCM, " _
, "ON DRAWMTWO.RECSEQ= WQMSTWOWCM.TWOINDX}" & Chr(13) & "" & Chr(10) & "WHERE,(DRAWMTWO.SHOP In (0,3,8,9)) AND (DRAWMTWO.TWOLOC<>'Closed'), " _
, "ORDER BY DRAWMTWO.DATEI DESC " _
)
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.ListObject.DisplayName = "Table_ExternalData_1"
.Refresh BackgroundQuery:=False
End With