Late to the game with this answer, but this is something that MS-Access developers occasionally need to do...
...And it's arcane, because we're going to use a read-only query with an internally-defined connection string, and the 'Query Properties' window doesn't quite do what you would expect it to do.
Actually, I don't think that window does whatever the Microsoft developer who implemented the 'Source Connection String' property expects it to do, either.
But, arcane or not, here's how to do something that works like a read-only linked table from another MS-Access database:
- First, create a new query on a local table. It doesn't matter what
table or what fields, you're discarding the SQL anyway.
- Right-Click in the query window's title bar and select 'SQL
View'
- Paste this SQL in, overwriting whatever was there:
SELECT *
FROM tblCustomer
IN "" [MS Access;PWD=WTF_En_Clair;DATABASE=\\MyServer\MyShare$\Subfolder\MyDB.accdb];
Don't miss out those double-quotes in front of the connection string: they aren't put in there for you by the built-in properties dialogue when you paste in a connection string, and you really do need them.
You're not yet done: it's still read-write:
- Right-Click in the query window title bar, and select 'Design
View'
- Right-click in the background area of the upper pane - the MDI
window where tables appear - and select 'Properties..."
- You'll probably get a 'Property Sheet' popup with two fields: 'Alias
and Source' - this is the table's property sheet, and you want the
query's property sheet...
- ...So left-click in the MDI background of the upper pane again to
get the full property sheet for the query.
- Set the 'Recordset Type' property to 'Snapshot'
- Right-click in the query window title bar and hit 'Save'.
- You're done with the query window. Don't do anything else here, just close the window.
.
You can rename the query to the table name, or not: it'll still work in any query as if it was a table, and you might just save some confusion if you give it a name that makes it clear that this isn't actually a table. This matters in any code that expects a DAO TableDef object, and that includes any code that re-links external tables for you.
You'll notice your connection string (plain text password and all) in the query properties window under 'Source Connection String'. Seriously, don't edit it: if you're lucky, it'll just replace your two double-quotes in the SQL with a pair of single quotes, and the query will still work. But you'll probably lose those quotes if you paste in a new connection string, and that'll break the query; and none of the error messages and help pages will tell you that you need these magic quote marks in the raw SQL.
I suspect that there are other undocumented 'gotcha' traps in queries to external objects: if you pass this hack on to your colleagues, I strongly advise you to pass on the warning 'You're done with the query window. Don't do anything else here' because this type of trap can waste hours of your time and theirs.
Also: be sure to document what you did: most of the tools for reconnecting linked tables won't pick up a query with an external source, and that's a bug waiting to bite whoever tries to hop between 'DEV', Testing' and 'Production' databases.