April 2006
Beginner
1114 pages
98h 16m
English
querytable.CommandText[= setting]
Sets or returns the command string for the specified query table. The following code returns the results of a query with the specified command string:
Dim strConn As String
Dim strSQL As String
Dim qt As QueryTable
strConn = "ODBC;DSN=MS Access Database;" & _
"DBQ=C:\Program Files\Microsoft Office\OFFICE11\SAMPLES\Northwind.mdb;"
Set qt = ActiveSheet.QueryTables.Add(Connection:=strConn, _
Destination:=ActiveSheet.Range("A1"))
qt.CommandText = "SELECT * FROM Products WHERE (Products.ProductID=10)"
qt.RefreshRead now
Unlock full access