I can not understand why you want to use 2 db and 2 recordset when Ican see from your codes that you are querying 2 tables.
Are you trying to open 2 databases?
Main Topics
Browse All TopicsWhat I would like to do is use 2 DAO recordset2, as below,
Dim db1 As DAO.Database
Dim rs1 As DAO.Recordset
Dim qdf1 As QueryDef
Set db1 = CurrentDb()
Set qdf1 = db1.CreateQueryDef("")
qdf1.SQL = "SELECT Table1.* " & _
"FROM Table1;"
Set rs1 = qdf1.OpenRecordset()
Dim db2 As DAO.Database
Dim rs2 As DAO.Recordset
Dim qdf2 As QueryDef
Set db2 = CurrentDb()
Set qdf2 = db2.CreateQueryDef("")
qdf2.SQL = "SELECT Table2.* " & _
"FROM Table2;"
Set rs2 = qdf2.OpenRecordset()
to create a third DAO recordset composed of a join query of the two previous, using the two DAO recordsets as the source tables, per the SQL below...
SELECT Table1.*, Table2.*
FROM Table1 INNER JOIN Table2 ON Table1.Field1 = Table2.Field2;
So something like
select rs1.*, rs2.*
from rs1 INNER JOIN rs2 on rs1.field1 = rs2.field2
however that select statement doesn't work as a qdf3.sql
Code samples would be appreciated, and are far more likely to get you points. ;-) Something in the syntax is what I'm missing I think
Thanks - Justin
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
No my interest in this is determined by speed. I carry about 8000 records per table, so every time I disconnect and reconnect it downloads the tables again. What I would like to do is load all my recordsets at the load of my application, and hold them in public memory... Running join queries on this would be extremely fast I think, as I already have the recordsets downloaded from the server-Catching my meaning? If there is an alternative method, I'd be glad to hear it-But I don't think saving info to a local table is the solution.
as already mentioned, the
select rs1.*, rs2.*
does not work.
how to achiev this:
do a temporary link to the external tables:
code example:
Dim dbsCurrent As Database
Dim tdfLinked As TableDef
Dim test As String
Set dbsCurrent = OpenDatabase(CurrentDb.Nam
Set tdfLinked = dbsCurrent.CreateTableDef(
tdfLinked.Connect = ";DATABASE=your ExtenalDBName"
tdfLinked.SourceTableName = "youeExternalTableName"
' dbsCurrent.TableDefs.Delet
dbsCurrent.TableDefs.Appen
so you can use the local tablename just like any local table in normal queries
maybe you can use stored quries, depending on what you exactly want to achieve
Regards, Franz
if you need further support on that, please post.
You can't join recordsets. They're not like tables and you don't have a db engine that would do it for you.
Doing it in code means taking a big CPU hit to save some netowkr traffic; a manual join e.g. nested loops in VB are going to be way slower than the DB engine doing the join.
What's wrong with:
Dim db2 As DAO.Database
Dim rs2 As DAO.Recordset
Dim qdf2 As QueryDef
Set db2 = CurrentDb()
Set qdf2 = db2.CreateQueryDef("")
qdf2.SQL = "SELECT Table1.*, Table2.*
FROM Table1 INNER JOIN Table2 ON Table1.Field1 = Table2.Field2;"
Set rs2 = qdf2.OpenRecordset()
BTW, Table1.* will pull all the columns from Table1. If you don't actually need them all, then list the column you ned epxlicity. That can save a lot of network traffic. Since you're joining on a common field, you should at least not list that field twice.
Cahce the result set rather than the two origianal tables.
Whichever way, if you cache clinet side then you will have to do some work if you are updating...
If you moved to ADO recordset you can create it in memory and then add the records from each seperate recordset with a loop (still no SQL) and get the eventual result you are after which is one large in memory recodset, you can bind this recordset to a form if you want and even do sorts and filters against it.
Steve
Business Accounts
Answer for Membership
by: jb79ukPosted on 2004-01-09 at 07:47:04ID: 10080807
Your main problem here is that you can't manipulate recordset objects in SQL (if someone knows how to, please let me know!). I think you will have to either save the results of your first SELECT statements to a table OR combine both SQL strings into one in the first place.
If you're concerned about bloating the database, you could possibly save the results of the queries out to external temporary files and link to those.
JB