Name
database.OpenRecordset(Source, [Type], [Options]), [LockEdits])
Synopsis
Opens the record.
|
Argument |
Description |
|---|---|
|
|
The source of the recordset: a table name, query name, or SQL statement. |
|
|
The type of recordset to open: |
|
|
A combination of constants that specify characteristics of the recordset. See DAO Help for more information about these options. |
|
|
The locking used by the recordset: |
The following code example opens the Employees table in the Northwind Traders sample database as a recordset and displays its contents on the active sheet:
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.RefreshBecome an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access