When attempting to create a “secured” workspace from a non-secured .MDB/.MDE file using the DAO CreateWorkspace method, Err 3029, Not a valid account name or password, results. I’ve used identical code in past and it worked fine – even posted an example last year. I’m using same version of Access (XP, 2000 format) and Jet (4.0 SP6) as when code worked OK. The purpose of the sub is to dynamically create a new user account for a user with non-admin permissions from an unsecured db file as part of a setup routine. (The rest of sub works fine – if already logged into secured db….) Example of code used:
Public Sub CreateNewUserAcct(ByVal strWrkgrpPath As String, _
ByVal strUser As String, _
ByVal strGrp As String, _
ByVal strPwd As String)
On Error GoTo Err_Handler
Dim ws As DAO.Workspace
Dim grp As DAO.Group
Dim usr As DAO.User
Dim strPID As String
Dim strMsg As String
strPID = “aBC123xyZ456”
DBEngine.SystemDB = strWrkgrpPath ‘ Full path of Wrkgrp file for secured DB
Set ws = DBEngine.CreateWorkspace(“SecureWS”, “SYSADMIN”, “XabcAc46Z1”, dbUseJet)
The code halts at the “Set ws” line and I get the Err 3029 msg. I tried this with 2 different databases, attempting to connect to 2 different secured db’s, w/same result. I double checked the password, path, etc, all are specified correctly. The problem seems to be with the DBEngine.SystemDB = strWrkgrpPath instruction – it does not appear to work. When code halts & enter command in debug window:
? DBEngine.SystemDB
C:Documents and SettingsMARK DApplication DataMicrosoftAccessSystem1.mdw
Which is the default (non-secured) .MDW on my system. According to Help file for SystemDB property:
[indent]
Sets or returns the path for the current location of the workgroup information file (Microsoft Jet workspaces only).
For this option to have any effect, you must set the SystemDB property before your application initializes the DBEngine object (that is, before creating an instance of any other DAO object). The scope of this setting is limited to your application and can’t be changed without restarting your application.
[/indent]
There is no other “instance of any other DAO object” created before running this code, AFAIK. It’d make more sense if SystemDB was a property of the Workspace rather than DBEngine object. What’s the use of being able to create a new Workspace object if you can’t specify a different SystemDB along with Username, password, etc?? The same code worked in past, so why not now? If anyone has any clues, plz advise!