Solved

db.OpenRecordset with linked tables

Posted on 2002-07-10
9
309 Views
Last Modified: 2010-05-18
I am running code that updates tables using the following:

Set rs = db.OpenRecordset("tblVendorNames1", DB_OPEN_TABLE)

I have what to me is an interesting problem.  When I try to use this code with linked tables I get run time error 3219 Invalid Operation.  When ever I try to use this with tables located in the front end it works fine.  I would like to keep all my tables located in the back end.  How can I get this to work with linked tables?
0
Comment
Question by:Hockey
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 7

Expert Comment

by:ildc
ID: 7143762
Set rs = db.OpenRecordset("tblVendorNames1", DB_OPEN_TABLE)
should be:
Set rs = db.OpenRecordset("tblVendorNames1", DBOPENTABLE)

But I advice your to use dbopendynaset if you want to change data, and dbopenforwardonly if you want to loop through data, and dbsnapshot if you want to see data

Regards
0
 

Author Comment

by:Hockey
ID: 7144163
That unfortunately, still did not do the trick.  Even using dynaset.
0
 
LVL 3

Expert Comment

by:kenspencer
ID: 7144392
Hi,

So,
        Set rs = db.OpenRecordSet("tblVendorNames1", dbOpenDynaset)

only works with your local tables and not your linked ones?

Ken
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 7

Expert Comment

by:Daniel Stanley
ID: 7144904
i ran into a similar problem, i couldn't find a way around it; i was only looking for one value so i used DLookup instead.

good luck,
daniels@asix.com
0
 
LVL 9

Expert Comment

by:perove
ID: 7145574
this is correct..that you get the error I'mean.

The db is set to the currentdb and not the MDB where the table resides.

Two way I can think of to fix it.

One use the correct setting when you are setting the db variable:

method 1
Function opendb()
Dim rs As Recordset
Dim db As Database
Set db =     Set Db = DBEngine.Workspaces(0).OpenDatabase("c:\linkedtablemdb.mdb")
Set rs = db.OpenRecordset("linkedtablemdb", dbOpenTable)
End Function

method 2
Make a query that select everything from the tblVendorNames1, save this query as tblVendorNames1Q

Then you can directly do a:
Set rs = db.OpenRecordset("tblVendorNames1Q", DB_OPEN_TABLE)


perove







0
 
LVL 9

Expert Comment

by:perove
ID: 7145578
Sorry... method 1 should be:

Function opendb()
Dim rs As Recordset
Dim db As Database
Set Db = DBEngine.Workspaces(0).OpenDatabase("c:\linkedtablemdb.mdb")
Set rs = db.OpenRecordset("linkedtablemdb", dbOpenTable)
End Function


slip of the finger

perove
0
 
LVL 7

Accepted Solution

by:
ildc earned 100 total points
ID: 7145590
Hi hockey,

I donnut know which version of access your using, but if it's 97 or later, it never hearts to declare your variables as :

dim db as dao.database
dim rs as dao.recordset

regards
0
 

Author Comment

by:Hockey
ID: 7149894
Ok guys thanks I will start to trying your suggestions.  

0
 

Author Comment

by:Hockey
ID: 7150247
Metod 1 worked thanks.
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question