ACC: Cannot Perform OpenTable Method on Linked/Attached Table (138769)
The information in this article applies to:
- Microsoft Access 1.0
- Microsoft Access 1.1
- Microsoft Access 2.0
- Microsoft Access for Windows 95 7.0
- Microsoft Access 97
This article was previously published under Q138769
Moderate: Requires basic macro, coding, and interoperability skills.
SYMPTOMS
If you try to open a recordset on a linked (attached) table by using the
dbOpenTable constant (or DB_OPEN_TABLE in version 2.0), you may receive the
following error message.
In Microsoft Access 7.0 and 97:
Run-time error '3219':
Invalid Operation.
In Microsoft Access 2.0:
Invalid Operation
In Microsoft Access 1.x:
Can't perform operation; it is illegal.
This article assumes that you are familiar with Visual Basic for
Applications and with creating Microsoft Access applications using the
programming tools provided with Microsoft Access. For more information
about Visual Basic for Applications, please refer to your version of the
"Building Applications with Microsoft Access" manual.
NOTE: Visual Basic for Applications is called Access Basic in Microsoft
Access versions 1.x and 2.0. For more information about Access Basic,
please refer to the "Introduction to Programming" manual in Microsoft
Access version 1.x or the "Building Applications" manual in Microsoft
Access version 2.0.
RESOLUTION
In Microsoft Access 2.0, 7.0, and 97:
In Microsoft Access 2.0, 7.0, and 97, 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.
Microsoft Access 7.0 and 97:
Public Function testLink()
Dim myDb As DATABASE, rstCustomers As 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
Microsoft Access 2.0:
Public Function testLink()
Dim myDb As DATABASE, rstCustomers As Recordset
' Open the Northwind.mdb database.
Set myDb = DBEngine.Workspaces(0).OpenDatabase("Northwind.mdb")
' Create the recordset.
Set rstCustomers = myDb.OpenRecordset("Customers", DB_OPEN_DYNASET)
End Function
In Microsoft Access 1.x:
In Microsoft Access 1.x, an attached table must be opened as the Dynaset
object as shown in the following example:
DIM MyDB as Database
DIM MyDynaset as Dynaset
Set MyDB = OpenDatabase("NWIND.MDB")
Set MyDynaset = MyDB.CreateDynaset("Customers")
STATUS
This behavior is by design.
REFERENCES
For more information about the OpenRecordset Method, search the Help
Index for "OpenRecordset."
For more information about how to use the Seek method with linked tables,
please see the following article in the Microsoft Knowledge Base:
131829 ACC: How to Use the Seek Method on Linked Tables
Modification Type: | Minor | Last Reviewed: | 10/11/2006 |
---|
Keywords: | kberrmsg kbprb kbProgramming KB138769 |
---|
|