Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can VB's DBEngine open 2 databases using 2 different MDW files? 2

Status
Not open for further replies.

ibanezGuitars

Programmer
Jul 8, 2004
22
US
Hello,

I am revamping a VB6 system that uses Microsost's DAO 3.6 Object Model and Access 2002 databases on a Win XP machine. There is a Master.mdb database on the server that everyone shares and there is a Local.mdb database on each user's local hard drive for their own individual needs.

Can I use 2 separate .mdw (security) files to open each database individually?

In other words, as users logon to the system, can I have all of the users open the Master.mdb file on the server using the same Master.mdw security file (also on the server) and then have each user open their individual Local.mdb files which reside on their local hard drive using their own copy of the Local.mdw file (also residing on each user's hard drive) ???

Any suggestions or code snippets would be greatly appreciated.

Thanks for your time,

Dave
 
The .mdw file is set by the database. I think your question is, "Can one instance of Access have two different databases open at the same time, if those databases use different .mdw files?" The answer to that question is yes:
Code:
Dim dbLocal as Database, dbMaster as Database
Set dbLocal = dbengine.CreateWorkspace([i]Local_DB_Name[/i],[i]Local_UserName[/i],[i]Local_Password[/i])
Set dbMaster = dbengine.CreateWorkspace([i]Master_DB_Name[/i],[i]Master_UserName[/i],[i]Master_Password[/i])
 
Looking at the documentation, I'm not sure that I can instantiate two of the DBEngine.SystemDB objects at the same time. The code for the master database on the server is as follows-

'Workgroup Administaration file on network
DBEngine.SystemDB = mstrAppPath & "\CMT.mdw"
Set mwsW2W = DBEngine.CreateWorkspace("", mLogID, mLogPW)
Set mdatW2W = mwsW2W.OpenDatabase(mstrAppPath & mstrMDB)

I access the mstrMDB database (on the server) utilizing the CMT.mdw Workgroup Administaration file also on the server. Can I open up the user's local database using a different local mdw file on each user's PC? The code for the local users database is as follows.

DBEngine.SystemDB = mstrLocalPath & "\Local.mdw"
Set mwsLocal = DBEngine.CreateWorkspace("", mLogID, mLogPW)
Set mdatLocal = mwsLocal.OpenDatabase(mstrLocalPath _ mstrLocalMDB)

I guess my question is can the DBEngine be used again to open a local database using a local mdw file located on the user's own PC without causing errors or disabling access to the master mdb that I just opened on the server (prior to this one)?

Thanks for your time,

Dave

 
ibanezGuitars,

Help said:
The Connection object is similar to a Database object. The principal difference is that a Database object usually represents a database, although it can be used to represent a connection to an ODBC data source from a Microsoft Jet workspace.[/quotes]
Check the OpenConnection Method from the help file where there is an example of using 3 connections...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top