M
marpetban
Rows 1,2,3 have input controls for the user.
When I execute the following, it is supposed to return the data to range=A4,
instead, it inserts 5 columns of data at A1.
Private Sub CommandButton1_Click()
' do query using dates from B1, B2
' NOTE: need to adjust dates by subtracting 36161 to match up with date
values
Dim qt As QueryTable
sqlstring = "SELECT INVOICE, CUSTOMERNAME, ITEM_REC, QUANTITY, AMOUNT FROM
TRANSACT"
connstring = "ODBC;DSN=Odyssey"
Set qt = ActiveSheet.QueryTables.Add(Connection:=connstring,
Destination:=ActiveSheet.Range("A4"))
qt.FillAdjacentFormulas = True
qt.CommandText = sqlstring
qt.CommandType = xlCmdSql
qt.Destination.ClearContents
qt.Refresh
End Sub
How do I get it to return the results to the location I specify?
When I execute the following, it is supposed to return the data to range=A4,
instead, it inserts 5 columns of data at A1.
Private Sub CommandButton1_Click()
' do query using dates from B1, B2
' NOTE: need to adjust dates by subtracting 36161 to match up with date
values
Dim qt As QueryTable
sqlstring = "SELECT INVOICE, CUSTOMERNAME, ITEM_REC, QUANTITY, AMOUNT FROM
TRANSACT"
connstring = "ODBC;DSN=Odyssey"
Set qt = ActiveSheet.QueryTables.Add(Connection:=connstring,
Destination:=ActiveSheet.Range("A4"))
qt.FillAdjacentFormulas = True
qt.CommandText = sqlstring
qt.CommandType = xlCmdSql
qt.Destination.ClearContents
qt.Refresh
End Sub
How do I get it to return the results to the location I specify?