Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

ACC2000: Cannot Perform OpenTable Method on Linked/Attached Table


View products that this article applies to.

This article was previously published under Q208379
Moderate: Requires basic macro, coding, and interoperability skills.

This article applies only to a Microsoft Access database (.mdb).

↑ Back to the top


Symptoms

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.

↑ Back to the top


Resolution

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.

NOTE: The sample code in this article uses Microsoft Data Access Objects. For this code to run properly, you must reference the Microsoft DAO 3.6 Object Library. To do so, click References on the Tools menu in the Visual Basic Editor, and make sure that the Microsoft DAO 3.6 Object Library check box is selected.

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
				

↑ Back to the top


More information

Steps to Reproduce Behavior

1.Create a new, blank database in the same folder as the sample database Northwind.mdb.
2.On the File menu, point to Get External Data, and then click Link Tables.
3.In the Link dialog box, click Northwind.mdb, and then click Link.
4.In the Link Tables dialog box, click the Customers table, and then click OK.
5.Create a module and type the following line in the Declarations section if it is not already there:
Option Explicit
					
6.Type the following procedure:
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

					
7.To test this function, type the following line in the Immediate window, and then press ENTER:
? Test()
						
Note that you receive the error message mentioned in the "Symptoms" section.

↑ Back to the top


References

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.

For additional information about how to use the Seek method with linked tables, click the article number below to view the article in the Microsoft Knowledge Base:
210266 ACC2000: How to Use the Seek Method on Linked Tables

↑ Back to the top


Keywords: KB208379, kbvba, kbprb, kbdta, kbprogramming, kberrmsg

↑ Back to the top

Article Info
Article ID : 208379
Revision : 1
Created on : 12/12/2002
Published on : 12/12/2002
Exists online : False
Views : 331