can not open database

M

Mei Qin

Hello,

I have a secured database. When I put the following in my
shortcut property Target:
"C:\Program Files\Microsoft
Office\OFFICE\MSACCESS.EXE" "C:\VIDCD\DATA\vid0603.MDB"
/wrkgrp "C:\VIDCD\DATA\VIDCD.MDA"
I can open it after I typied in UserID and Password.

But when I tried to open it in my code:


Dim ws As Workspace
With DBEngine
.SystemDB = "c:\VIDCD\DATA\VIDCD.MDA"
End With
Set ws = DBEngine.CreateWorkspace
("New", "myid", "mypassword")
Set OpenDB = ws.OpenDatabase("c:\vidcd\data\vid0603.mdb")

I got the "Not a valid account Name or password" error at
createWordspace line.

What is the problem?

Thanks for any help!

mei
 
S

Scott McDaniel

Is this your full code or a snippet? Are you doing this from within Access?
If so, you can't change the SystemDB like that ... the only way to change
SystemDB for the current session of Access is to close/reopen Access.

You can open another database using syntax similar to this:

Dim dbg As New DBEngine
Dim wks As DAO.WorkSpace

dbg.SystemDB = "YourPath"
Set wks = dbs.CreateWorkspace(blah)
etc etc
\
 
M

Mei Qin

Yes, I am doing this from within Access. And I am trying
to open anothere database.

I did the following:
Dim dbg As New DBEngine
Dim wks As DAO.WorkSpace

dbg.SystemDB = "YourPath"
Set wks = dbg.CreateWorkspace(blah)

Still got the error for "Not a valid account Name or
password"

What else should I try?

Thanks for your help!

Mei
 
S

Scott McDaniel

Sorry ... you must provide the username and password for the Workspace
object:


Set dbg = New DAO.DBEngine
dbg.SystemDB = "PathtoYourWorkgroupFile"
Set wks = dbg.CreateWorkspace("", "UserName", "Password")
Set dbs = wks.OpenDatabase("PathToDatabase")

Check online help for more information on CreateWorkspace and OpenDatabase
....
 
T

TC

Or:

dim e as privdbengine, db as database
set e = new privdbengine
e.systemdb = ...
e.defaultuser = ...
e.defaultpassword = ...
set db = e.opendatabase (...)


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