Hi ODW:)
Maybe I should reconsolidate and clarify:) In the context of your original question, the answer is:
You can't do it via SQL/Query Builder, if the databases are: both Access, and have a different mdw. However, if both databases are Access and have the same mdw, (as your later comment indicated) then you can do it via SQL/Query Builder. In that specific scenario you would not (can't) do it via a connection string you would do it following the steps 1-4 below, then replace step 5a with 5b.
If the databases are both Access and have a different mdw, the only way to specify a different workgroup is with the connection string. However the SQL/Query Builder will throw a ISAM error if you try to via the connection string property (in step 5a below). So you can't do it via the Query builder. You can do it with VBA using ADO as in my example posted previously.
Remember that the connection string property in the query builder is for non-Access databases, source database is for Access databases with the same (or no) mdw. For Access databases with different mdws the only solution I am aware of is the VBA one I posted previously.
Now as to using the connection string directly in SQL. You can do this. But there are some caveats: It won't work with other Access databases. If you do it with SQL Sever dbo tables, you will have to edit the SQL the query builder generates to remove the "dbo." prefix.
I think the simplest way is to just walk you through what I am trying to say.
- Set up a working connection string to a non-access database. (I suggest to keep it easy, just use an Excel file.)
- Once you have the string open the query builder in Access.
- Close the select table dialog.
- Press Alt-Enter to open Query Properties.
5a. In "Source Connect Str" paste the Connection String.
*5b. Paste the path to the other database in "Source Database".
- Now add your tables and build your query.
- Go to the SQL view. See what was built.
But it's almost irrelevant as this approach, while valid for non-Access databases, does not work for Access. (It's a bit frustrating I know.)
Example of connection string in use:
SELECT [Sheet1$].F1
FROM [Sheet1$] IN '' [Excel 5.0;HDR=NO;IMEX=2;DATABASE=C:\Users\Oorang\Documents\Book1.xls];
I really do not think it is valid
ACE/Jet syntax to put an OLE DB
connection string into the IN database
clause.
Just as an FYI, you use the connection string, as shown above, but if you use the Source Db property, you will get what is below:) (I tested all my examples before I posted them:))
SELECT *
FROM Table1 IN 'C:\Users\Oorang\Documents\db2.mdb';