• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1298
  • Last Modified:

DBEngine.SystemDB Question???

I am trying to open a Secured front-end database that uses a workgroup file using the following code.  myID and myPSWD are valid in mySecured.mdw but the code errors out each time indicating that the user and password is invalid.  It seems like the  DBEngine.SystemDB = "C:\MyFolder\mySecured.mdw"  is not working because when I mouse over this line in the debug window it is always referencing the original  C:\Program Files\.......\System.mdw.


Dim rst As Recordset
Dim dbs As database
Dim wks As Workspace
Dim varLastMod As Date

DBEngine.SystemDB = "C:\MyFolder\mySecured.mdw"

Set wks = CreateWorkspace("NewWks", "myID", "myPSWD")
Set dbs = wks.OpenDatabase("C:\MyFolder\MyDatabase.mdb")

Set rst = dbs.OpenRecordset("SetupGeneral", dbOpenDynaset)
rst.MoveFirst
varLastMod = rst!LAST_MODIFIED

MsgBox varLastMod
   
End Sub


Any help will be appreciated.
0
Eric Sherman
Asked:
Eric Sherman
  • 4
  • 4
1 Solution
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
You can't change the SystemDB of your current Access session. You can try open a new dbengine and use that;

Dim dbg As DAO.DBEngine
Dim rst As Recordset
Dim dbs As database
Dim wks As Workspace
Dim varLastMod As Date

Set dbg = New DAO.DBEngine
dbg.SystemDB = "C:\MyFolder\mySecured.mdw"

Set wks = dbg.CreateWorkspace("NewWks", "myID", "myPSWD")
Set dbs = wks.OpenDatabase("C:\MyFolder\MyDatabase.mdb")

Set rst = dbs.OpenRecordset("SetupGeneral", dbOpenDynaset)
rst.MoveFirst
varLastMod = rst!LAST_MODIFIED

MsgBox varLastMod
0
 
Eric ShermanAccountant/DeveloperAuthor Commented:
Tried it but same problem.  It is still pointing to the original System.mdw.

I need a way to be able to run the original code but without opening a session of Access.

Thanks,

ET

0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
What do you mean when you say "it's still pointing to your original system.mdw"? Do you mean that you can't open the recordset, database, etc? Are you getting any errors?

Try using this:

Set dbg = New PrivDBEngine

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Eric ShermanAccountant/DeveloperAuthor Commented:
It still errors out and when I mouse over the dbg.SystemDB = "C:\MyFolder\mySecured.mdw" it shows where dbg.SystemDB = C:\Program Files\.......\System.mdw.

I think I need to convert this VB code to an EXE.  Probably will need the Professional or Stand Alone version of Visual Basic as I don't see any options to Make EXE from the current modules that's open.

ET


0
 
Eric ShermanAccountant/DeveloperAuthor Commented:
LSM ... This worked.

Set dbg = New PrivDBEngine

What is the difference, comparing that code to ....

Set dbg = New DAO.DBEngine

Thanks,

ET






0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
The PrivDBEngine is a "private" db engine ... DAO sometimes has trouble building a new dbengine, which is why MS provided the Private dbengine ... BTW, this is not documented, so be forewarned ... it's been in every version of Access since 2000, but there are no guarantees for the future.
0
 
Eric ShermanAccountant/DeveloperAuthor Commented:
Ok ....Much Appreciated.

One last question..... The version of Visual Basic that opens up with Access 2000 is not capable of creating an EXE file of the code, correct???  Would I need the Professional version installed in order to accomplish this???

Thanks,

ET
0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
You are correct - Access uses VBA (which is a subset of the VB language) and you cannot create .exe files. You would have to have a full version of VB to do this.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now