ACC: Cannot Perform OpenTable Method on Linked/Attached TableLast reviewed: August 28, 1997Article ID: Q138769 |
The information in this article applies to:
SYMPTOMSModerate: Requires basic macro, coding, and interoperability skills. If you attempt to open a recordset on a linked (attached) table 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 OperationIn 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.
RESOLUTIONIn 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 FunctionMicrosoft 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 FunctionIn 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") STATUSThis behavior is by design.
MORE INFORMATION
Steps to Reproduce Behavior
REFERENCESFor 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:
ARTICLE-ID: Q131829 TITLE : ACC: How to Use the Seek Method on Linked Tables Keywords : JetRS kberrmsg kbprg PgmObj Version : 1.0 1.1 2.0 7.0 97 Platform : WINDOWS Hardware : x86 Issue type : kbprb Solution Type : kbcode |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |