With ActiveSheet.ListObjects.Add(SourceType:=0, Source:= _
"ODBC;DSN=REPORTDB;UID=reports;PWD=reports;SERVER=REPORTDB;", Destination:=Range("$A$1") _
).QueryTable
.CommandText = Array( _
"SELECT NCM_HEADER.NCR_KEY, NCM_HEADER.PART_NUMBER, NCM_HEADER.PART_NAME, NCM_HEADER.NCR_DISPLAY_STATUS, NCM_HEADER.WORK_ORDER, NCM_SIGNOFF.GROUP_NAME, NCM_SIGNOFF.DATE_IN_QUEUE" & Chr(13) & "" & Chr(10) _
& "FROM HMS.NCM_HEADER NCM_HEADER, HMS.NCM_SIGNOFF NCM_SIGNOFF" & Chr(13) & "" _
, _
"" & Chr(10) & "WHERE NCM_HEADER.NCR_KEY = NCM_SIGNOFF.NCR_KEY AND ((NCM_HEADER.WORK_ORDER = '03530' And (NCM_HEADER.NCR_DISPLAY_STATUS = 'OPEN'))" _
)
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.ListObject.DisplayName = "Table_Query_From_REPORTDB_1"
.Refresh BackgroundQuery:=False
End With
问题以SELECT NCM开始和结束一直到'打开'。我似乎无法让这个工作,虽然我有相同的模式和DB工作的其他代码。只是找不到粗体字符串的错误。
在OPEN之后进行编辑))“_);现在给出类型不匹配。