I am working on an Access database that has linked tables to a DB2 database via DSN ODBC connection.
All of the tables use the same System DSN since they're both in the same DB2 database. To get one group of tables, I use the system DSN "A" with one userid and password, and for the other group of tables, I use the same system DSN "A" as in the first group of tables, but with another userid and password.
This wrecked havoc in Access since if I open a table from the first group, it would cache the credentials and then if i tried to open a table from the second group without restarting Access, it would throw an Invalid credentials/username
error.
Using this answer I was able to work my way around it: I created two different System DSN ODBC connections, one for each group of tables. This allows me to open the tables from either group without authorization errors in the same session (e.g. wihtout having to restart Access).
I was wondering, if there's a way in Windows 10 and Office 365 (via vba, AutoExec macro, changing the registry, policies, etc.) to change the default behaviour of CurrentProject.AccessConnection.Properties("Cache Authentication")
from True
to False
This property is readonly once the database is opened.
So another thought I had is: if you open a remote database with the cache authentication set to False and add it to your workspace in another database, can you run queries via DAO in VBA in that "remote" database?
For example: Database "A" has all of the linked tables to DB2. From another database "B" I open Database "A" and add it to Database "B"'s workspace with Cache Authentication set to false (<- is this possible?) vía OpenConnection
? or OpenDatabase
. Once Database "A" is opened from Database "B", would I be able to run on-the-fly queries (meaning no stored proc) in database "B" using VBA referencing the linked tables in Database "A"?
UPDATE
According to Access 2003 VBA Programmer's Reference p.556 one can't specify advanced options using OpenConnection
This question has been asked before several times: