Link to home
Start Free TrialLog in
Avatar of Friggin_Lazy
Friggin_LazyFlag for United States of America

asked on

Query Two Tables in seperate databases

Hello Everyone
   Say i have two Access databases:
        Database1.accdb
        Database2.accdb
   I'm within Excel i'm using VBA:
     I can connect to one database by using:

          Set objConnection = New ADODB.Connection
          objConnection.Mode = adModeRead
          objConnection.Open connectionString
         sqlString = "SELECT * FROM Table1"

         Set objRecordSet = objConnection.Execute(sqlString)

  however, is it possible to connect to two seperate databases...
  to do a join query?

thanks in advance..
Avatar of Richard Daneke
Richard Daneke
Flag of United States of America image

It would be easier to do the join query in either Access database and then, open the join query from Excel.
If you could do this in Access, it would be much simpler - just link both tables, and then you can work with them as needed. Using ADO from Excel, you'd not be able to join two tables from different data sources.
Create a third database that has these two tables attached to it.  Then you can run your join query against this new database.  You can create the database and attach tables manually or with ADOX.
ASKER CERTIFIED SOLUTION
Avatar of Rory Archibald
Rory Archibald
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Friggin_Lazy

ASKER

Sorry for my delay.   This solution did it.. THANK YOU!