Hi, i get the same runtime error in my VBA macro. My code is below. now the funny thing is if I delete "StartInsTime" my code runs, but if I include it i get the runtime error. Any clues on how to resolve this?
With ActiveSheet.QueryTables.Add(Connection:=Array( _
"OLEDB;Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=True;Initial Catalog=Mscan100_db;Data Source=IntelDb2\MSSQL20" _
, _
"08;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=INTELDB2;Use Encryption for Data=False;Tag wi" _
, "th column collation when possible=False"), Destination:=Range("A1"))
.CommandType = xlCmdSql
'.CommandText = Array(sel_clause & frm_clause & whe_clause)
.CommandText = Array( _
"SELECT DISTINCT " & "LotSn" & "," & "Orientation" & "," & "PanelSn" & "," & IP & "." & IPI & "," & "StartInspTime" & "FROM InspPasses Inner Join " & IPS & " ON InspPassSubstrates.InspPassID = InspPasses.InspPassID Inner Join" & Chr(10) & " InspRunSubstrates ON InspRunSubstrates.InspRunSubstID = InspPas" _
, _
"sSubstrates.InspRunSubstID Inner Join" & Chr(10) & " InspPassDefects ON ((InspPassDefects.hlp_SubstID = InspRunSubstrates.SubstID) AND (InspPassDefects.hlp_InspPassID = InspPasses.InspPassID)) Inner Join" & Chr(10) & " BT_DefectResultCode ON BT_Def" _
, _
"ectResultCode.DefectResultCodeID = InspPassDefects.DefectResultCodeID Inner Join" & Chr(10) & " InspRuns ON InspRuns.InspRunID = InspPasses.InspRunID Inner Join" & Chr(10) & " BT_InspRuns ON BT_InspRuns.BT_InspRunID = InspRuns.BT_InspRunID Inner Jo" _
, _
"in" & Chr(10) & " BT_Products ON BT_Products.ProdID = BT_InspRuns.ProdID Inner Join" & Chr(10) & " BT_DieCoordinates ON ((BT_DieCoordinates.DieNr = InspPassDefects.hlp_DieNr) AND (BT_DieCoordinates.SubstTypeID = BT_Products.SubstTypeID)) " & Chr(10) & " Where" _
, " InspPasses.InspPassID in ('8135')")
.Name = "INTELDB2_MSSQL2008 Mscan100_db"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.SourceConnectionFile = _
"C:\Documents and Settings\Valued Customer\My Documents\My Data Sources\INTELDB2_MSSQL2008 Mscan100_db.odc"
.Refresh BackgroundQuery:=False
End With
End Sub
Bookmarks