LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 114
Default Excel VBA Query Across Databases

On May 9, 7:18*am, Chris C wrote:
Within the same sub/procedure/function, can I open one database, close it,
and open the other?

Yes. You could query the first set of data, cache the results in an
array (using getRows()), then run the second query on the other DB.

Alternative: Is it possible to have one function, connecting to DB1, be
called from a wrapper function that is connecting to DB2?

Don't see why not.

Tim



"Tim Williams" wrote:
You'll need to either create a linked table in one of your db's or
"manually" perform the join from 2 separate recordsets.


Tim


"Chris C" wrote in message
...
I'm trying to populate a recordset with 2 tables from seperate databases.
So
far, I get no error when I run the query, but it's also not populating the
field from the second database (which happens to be the one I'm actively
in).


The query is below:


With comboPubs
* *' Assign the Connection object.
* *.ActiveConnection = cnPubs
* *' Extract the required records.
* *.Open "select strName from db1_name..TblAnalysisOptions AO join
db2_name..TblResultHeader RH on
AO.guidAnalysisOptions=RH.guidAnalysisOptions"


* *' Copy the records into cell A1 on Sheet1.
* *Sheet1.Range("A1").CopyFromRecordset comboPubs


* *' Tidy up
* *.Close
End With


Is there anyway to do this? Both our on the same machine.- Hide quoted text -


- Show quoted text -




 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to access databases from excel using ms query and odbc? Nabin Excel Discussion (Misc queries) 0 October 11th 06 07:32 AM
Excel Templates and databases ChadF Excel Programming 3 September 7th 06 05:49 PM
Connecting two databases in MS Query Dean Excel Worksheet Functions 3 August 24th 06 09:22 PM
Excel and Databases Stanley Excel Discussion (Misc queries) 4 December 28th 05 10:25 PM
Querying 2 databases with one query string Ben Latham Excel Discussion (Misc queries) 0 October 25th 05 09:17 PM


All times are GMT +1. The time now is 09:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"