can not open database

  • Thread starter Thread starter Mei Qin
  • Start date Start date
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
 
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
\
 
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
 
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
....
 
Or:

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


TC
 
Back
Top