Solved

db.OpenRecordset with linked tables

Posted on 2002-07-10
9
286 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
 
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now