Using VB to Open Database

X

Xcelsoft

I have an Access 2k database that has a WorkGroup
Information File (Users and Permissions) used to open
it. I want to set the "AllowByPassKey" property to false
to prevent users from bypassing the startup menu and
options. I have the code to do this but the problem I am
having is opening the database from another database to
set or unset the "AllowByPassKey" property using VB. I
don't know how to specify the WorkGroup Information File
using the OpenDatabase command. This is necessary
because at times Admins will need to have the
AllowByPassKey set to True to bypass the startup options
for maintenance. The Shortcut to open the database with
the WorkGroup Information File is:

"C:\MyDBFolder\MYDatabase.mdb" /WRKGRP "C:\MyDBFolder\Secu
red.mdw"

In the VB function to set the AllowBypassKey Property I
need to open the database using the following:

Dim dbs
Set dbs = OpenDatabase("c:\MyDBFolder\MYDatabase.mdb")

Without the WorkGroup Information File specified, the
code errors out.

Any help will be appreciated.

Thanks
 
X

Xcelsoft

Thanks Doug,

I found the article but am now having a problem getting
the DBEngine.SystemDB to recognize the proper Workstation
Information File. See code below.

When I check the contents of the variable (myWorkspace),
the SystemDB still shows
as //ProgramFiles/CommonFiles/System/System.mdw instead
of the Worgroup Information File in the code.

Dim dbs As Database, prp As Variant, myWorkspace As
Workspace

DBEngine.SystemDB = "c:\MyFolder\secured.mdw"

Set myWorkspace = DBEngine.CreateWorkspace
("New", "MyUser", "MyPassword")
Set dbs = DBEngine.Workspaces("New").OpenDatabase
("c:\MyFolder\MyDatabase.mdb")

The Error Not a valid account name or password pops up.
I also checked the original System.mdw and the user name
appears to be there.

Thanks,
 
T

TC

It seems to me that you are not *using* the workspace that you created with
the specified username & password.

Try MYWORKSPACE.OpenDatabase.

HTH,
TC
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top