ACC2000: Cannot Perform OpenTable Method on Linked/Attached TableID: Q208379
|
If you try to open a recordset on a linked table by using the dbOpenTable constant, you may receive the following error message:
Run-time error '3219':
Invalid Operation.
In Microsoft Access, a linked table must be opened as the Recordset object. The following code example assumes that you are linked to the Customers table in the sample database Northwind.mdb, which resides in the same folder as the database containing this code. The code opens the Northwind.mdb file, which actually contains the Customers table. The code then creates a recordset based on the Customers table.
The sample code in this article uses Microsoft Data Access
Objects. For this code to run properly, you need to reference
the Microsoft DAO 3.6 Object Library.
Public Function testLink()
Dim myDb As DAO.DATABASE, rstCustomers As DAO.Recordset
' Open the Northwind.mdb database.
Set myDb = DBEngine.Workspaces(0).OpenDatabase("Northwind.mdb")
' Create the recordset.
Set rstCustomers = myDb.OpenRecordset("Customers", dbOpenDynaset)
End Function
Option Explicit
Function Test()
Dim db as DAO.Database
Dim mySet as DAO.Recordset
Set db = CurrentDB()
' Create the recordset based on the Customers table.
Set mySet = db.OpenRecordset("Customers", dbOpenTable)
End function
? Test()
Note that you receive the error message mentioned in the "Symptoms"
section.For more information about the OpenRecordset method, in the Visual Basic Editor, click
Microsoft Visual Basic Help on the Help menu, type "OpenRecordset" in
the Office Assistant or the Answer Wizard, and then click Search to
view the topic.
Additional query words: prb
Keywords : kberrmsg kbprg kbdta AccCon PgmObj KbVBA
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbprb
Last Reviewed: May 13, 1999