April 2006
Beginner
1114 pages
98h 16m
English
querytable.Recordset[= setting]
Sets or returns a Recordset object that serves as the data source for the specified query table. The following code creates a query table using the Employees table in the Northwind Traders sample database as the recordset and inserts the name of the recordset as well as the recordset data in the active worksheet:
Dim strDbPath As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim qt As QueryTable
strDbPath = "C:\Program Files\Microsoft Office\" & _
"OFFICE11\SAMPLES\Northwind.mdb"
Set db = OpenDatabase(strDbPath)
Set rs = db.OpenRecordset("Employees")
Set qt = ActiveSheet.QueryTables.Add(Connection:=rs, _
Destination:=ActiveSheet.Range("A3"))
ActiveSheet.Range("A1") = qt.Recordset.Name & " table:"
qt.RefreshRead now
Unlock full access