Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

db.OpenRecordset with linked tables

Posted on 2002-07-10
9
Medium Priority
?
380 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
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 400 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
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, when working with VBA, learn some techniques for writing readable and easily maintained code.

604 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