G
Gargoyle
OS: XP Home, Access: 2003Pro
Okay, here's an oddity . . .
Two databases, each with identical tables (TDFs). Data stored in the
tables is split across the 2 DBs, so half of the data is stored in the
tables of DB1, other half of the data is stored in the tables of DB2.
DB1 does not have its database-password set.
However, DB2 DOES have a database-password.
Problem: how to programmatically open DB2 from within DB1 at run-time?
I've tried these approaches:-
Approach#1:
DBEngine.Workspaces(0).OpenDatabase("C:\DB2.mdb", False, False,
"ODBC;pwd=xxxxx")
Database.Connection.OpenRecordset("Table1")
Approach#2 (gleaned from Access help files):
Set wrkJet = CreateWorkspace("", " user-level-username",
"user-level-password", dbUseJet)
Set dbsDB1 = wrkJet.OpenDatabase("C:\DB2.mdb", False, False,
";pwd=xxxxx")
Set rstDB1 = dbszpwd1.OpenRecordset("Table1")
where wrkJet, dbs, and rst are Workspace, Database and Recordset
respectively.
With Approach#1 I get Error 3151. Fair enough.
With Approach#2 I can open the database and access the table (although
I do get an annoying MsgBox saying "Opening DB2…", which I have to
click to close and then there is a noticeable delay before any results
from reading the table are available.
I'm not used to working with multiple DBs this way, usually I just use
front/back end approach and linked-tables, so I accept that there
might be better ways.
Can anyone point me in the direction of some sample code?
Thanks.
Okay, here's an oddity . . .
Two databases, each with identical tables (TDFs). Data stored in the
tables is split across the 2 DBs, so half of the data is stored in the
tables of DB1, other half of the data is stored in the tables of DB2.
DB1 does not have its database-password set.
However, DB2 DOES have a database-password.
Problem: how to programmatically open DB2 from within DB1 at run-time?
I've tried these approaches:-
Approach#1:
DBEngine.Workspaces(0).OpenDatabase("C:\DB2.mdb", False, False,
"ODBC;pwd=xxxxx")
Database.Connection.OpenRecordset("Table1")
Approach#2 (gleaned from Access help files):
Set wrkJet = CreateWorkspace("", " user-level-username",
"user-level-password", dbUseJet)
Set dbsDB1 = wrkJet.OpenDatabase("C:\DB2.mdb", False, False,
";pwd=xxxxx")
Set rstDB1 = dbszpwd1.OpenRecordset("Table1")
where wrkJet, dbs, and rst are Workspace, Database and Recordset
respectively.
With Approach#1 I get Error 3151. Fair enough.
With Approach#2 I can open the database and access the table (although
I do get an annoying MsgBox saying "Opening DB2…", which I have to
click to close and then there is a noticeable delay before any results
from reading the table are available.
I'm not used to working with multiple DBs this way, usually I just use
front/back end approach and linked-tables, so I accept that there
might be better ways.
Can anyone point me in the direction of some sample code?
Thanks.