Quering a changing range SQL
No, here is the code for the query, notice after WHERE it is referring to a
range different from statying every single element of that range ie
WHERE (ECL.LORD= cellA1.value AND ECL.LORD= cellA2.value AND ECL.LORD=
cellA3.value and so on................. that is wath I'm trying to accomplish
With ActiveSheet.QueryTables.Add(Connection:="ODBC;DSN= Cott;", Destination _
:=Range("A1"))
.CommandText = Array( _
"SELECT ECL.LCARR, ECL.LDESC, ECL.LORD, ECL.LQSHP, ECL.LUM" &
Chr(13) _
& "" & Chr(10) & "FROM PRDBPCS.PRODF.ECL ECL" & Chr(13) & "" &
Chr(10) _
& "WHERE (ECL.LORD= '" & Qrange & "')" _
& Chr(13) & "" & Chr(10) & "ORDER BY ECL.LORD, ECL.LDESC")
.Name = "Query from Cott_1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With
|