MDW Security and new Access instance

A

ADB_Seeker

Using a command button on a form, I want to open a new instance of Access and
then open a secured DB. I used code from The Access Web
(http://www.mvps.org/access/modules/mdl0036.htm) and am having trouble
personalizing it. When I click on the command button, I get a run-time error
4265. Following is my code:

Private Sub lblECSMgmtDB_Click()
Dim strDB As String
Dim strCmd As String
Dim objSecuredDB As Access.Application
strDB = "[\\Helialabama\engsys$\DataBases\ECS MNGT1.0.mdb]"
strCmd = SysCmd(acSysCmdAccessDir) & "[C:\Program Files\Microsoft
Office\Office10\MSACCESS.EXE] " _
& strDB & " /wrkgrp " & [Secured Management.mdw] _
& " /user Admin" "/pwd ''"
Call Shell(strCmd, vbNormalFocus)
DoEvents: DoEvents: DoEvents
Set objSecuredDB = GetObject(strDB)
Stop
End Sub

Thanks in advance for all help.
Linda
 
D

Dirk Goldgar

ADB_Seeker said:
Using a command button on a form, I want to open a new instance of Access
and
then open a secured DB. I used code from The Access Web
(http://www.mvps.org/access/modules/mdl0036.htm) and am having trouble
personalizing it. When I click on the command button, I get a run-time
error
4265. Following is my code:

Private Sub lblECSMgmtDB_Click()
Dim strDB As String
Dim strCmd As String
Dim objSecuredDB As Access.Application
strDB = "[\\Helialabama\engsys$\DataBases\ECS MNGT1.0.mdb]"
strCmd = SysCmd(acSysCmdAccessDir) & "[C:\Program Files\Microsoft
Office\Office10\MSACCESS.EXE] " _
& strDB & " /wrkgrp " & [Secured Management.mdw] _
& " /user Admin" "/pwd ''"
Call Shell(strCmd, vbNormalFocus)
DoEvents: DoEvents: DoEvents
Set objSecuredDB = GetObject(strDB)
Stop
End Sub

Thanks in advance for all help.
Linda


Hi, Linda. What's with all the square brackets? Try this:

'------ start of code ------
Private Sub lblECSMgmtDB_Click()

Dim strDB As String
Dim strWrkgrp As String
Dim strPW As String
Dim strCmd As String
Dim objSecuredDB As Access.Application
Const Q As String = """"

' Note: the following line is constructed with concatenation just so
' that it will post correctly, without being interpreted as a hyperlink.
strDB = "\\" & "Helialabama\engsys$\DataBases\ECS MNGT1.0.mdb"

strWrkgrp = "Secured Management.mdw"
strPW = "" ' your password here>

strCmd = _
Q & SysCmd(acSysCmdAccessDir) & "\MSACCESS.EXE" & Q & _
" " & Q & strDB & Q & " /wrkgrp " & strWrkgrp & _
" /user Admin" "/pwd " & strPW

Shell strCmd, vbNormalFocus

DoEvents: DoEvents: DoEvents

Set objSecuredDB = GetObject(strDB)

' ... process using objSecuredDB

End Sub
'------ end of code ------

Note that you may need to specify full path for the workgroup file as well;
if so, you may need to wrap quotes around that, as I did with the Access
path and the database path.
 
A

ADB_Seeker

I thought I had to have the square brackets when spaces were involved.

Do I have to put in a specific password or will Access open the DB and
request a userid/password?

What do the "Qs" stand for?

Thank you

Dirk Goldgar said:
ADB_Seeker said:
Using a command button on a form, I want to open a new instance of Access
and
then open a secured DB. I used code from The Access Web
(http://www.mvps.org/access/modules/mdl0036.htm) and am having trouble
personalizing it. When I click on the command button, I get a run-time
error
4265. Following is my code:

Private Sub lblECSMgmtDB_Click()
Dim strDB As String
Dim strCmd As String
Dim objSecuredDB As Access.Application
strDB = "[\\Helialabama\engsys$\DataBases\ECS MNGT1.0.mdb]"
strCmd = SysCmd(acSysCmdAccessDir) & "[C:\Program Files\Microsoft
Office\Office10\MSACCESS.EXE] " _
& strDB & " /wrkgrp " & [Secured Management.mdw] _
& " /user Admin" "/pwd ''"
Call Shell(strCmd, vbNormalFocus)
DoEvents: DoEvents: DoEvents
Set objSecuredDB = GetObject(strDB)
Stop
End Sub

Thanks in advance for all help.
Linda


Hi, Linda. What's with all the square brackets? Try this:

'------ start of code ------
Private Sub lblECSMgmtDB_Click()

Dim strDB As String
Dim strWrkgrp As String
Dim strPW As String
Dim strCmd As String
Dim objSecuredDB As Access.Application
Const Q As String = """"

' Note: the following line is constructed with concatenation just so
' that it will post correctly, without being interpreted as a hyperlink.
strDB = "\\" & "Helialabama\engsys$\DataBases\ECS MNGT1.0.mdb"

strWrkgrp = "Secured Management.mdw"
strPW = "" ' your password here>

strCmd = _
Q & SysCmd(acSysCmdAccessDir) & "\MSACCESS.EXE" & Q & _
" " & Q & strDB & Q & " /wrkgrp " & strWrkgrp & _
" /user Admin" "/pwd " & strPW

Shell strCmd, vbNormalFocus

DoEvents: DoEvents: DoEvents

Set objSecuredDB = GetObject(strDB)

' ... process using objSecuredDB

End Sub
'------ end of code ------

Note that you may need to specify full path for the workgroup file as well;
if so, you may need to wrap quotes around that, as I did with the Access
path and the database path.

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)
 
A

ADB_Seeker

Also, I receive a Syntax Error when I click on the command button. It is on
the "strCmd = " line of code.

Thank you in advance for your help.
Linda

ADB_Seeker said:
I thought I had to have the square brackets when spaces were involved.

Do I have to put in a specific password or will Access open the DB and
request a userid/password?

What do the "Qs" stand for?

Thank you

Dirk Goldgar said:
ADB_Seeker said:
Using a command button on a form, I want to open a new instance of Access
and
then open a secured DB. I used code from The Access Web
(http://www.mvps.org/access/modules/mdl0036.htm) and am having trouble
personalizing it. When I click on the command button, I get a run-time
error
4265. Following is my code:

Private Sub lblECSMgmtDB_Click()
Dim strDB As String
Dim strCmd As String
Dim objSecuredDB As Access.Application
strDB = "[\\Helialabama\engsys$\DataBases\ECS MNGT1.0.mdb]"
strCmd = SysCmd(acSysCmdAccessDir) & "[C:\Program Files\Microsoft
Office\Office10\MSACCESS.EXE] " _
& strDB & " /wrkgrp " & [Secured Management.mdw] _
& " /user Admin" "/pwd ''"
Call Shell(strCmd, vbNormalFocus)
DoEvents: DoEvents: DoEvents
Set objSecuredDB = GetObject(strDB)
Stop
End Sub

Thanks in advance for all help.
Linda


Hi, Linda. What's with all the square brackets? Try this:

'------ start of code ------
Private Sub lblECSMgmtDB_Click()

Dim strDB As String
Dim strWrkgrp As String
Dim strPW As String
Dim strCmd As String
Dim objSecuredDB As Access.Application
Const Q As String = """"

' Note: the following line is constructed with concatenation just so
' that it will post correctly, without being interpreted as a hyperlink.
strDB = "\\" & "Helialabama\engsys$\DataBases\ECS MNGT1.0.mdb"

strWrkgrp = "Secured Management.mdw"
strPW = "" ' your password here>

strCmd = _
Q & SysCmd(acSysCmdAccessDir) & "\MSACCESS.EXE" & Q & _
" " & Q & strDB & Q & " /wrkgrp " & strWrkgrp & _
" /user Admin" "/pwd " & strPW

Shell strCmd, vbNormalFocus

DoEvents: DoEvents: DoEvents

Set objSecuredDB = GetObject(strDB)

' ... process using objSecuredDB

End Sub
'------ end of code ------

Note that you may need to specify full path for the workgroup file as well;
if so, you may need to wrap quotes around that, as I did with the Access
path and the database path.

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)
 
D

Dirk Goldgar

ADB_Seeker said:
Also, I receive a Syntax Error when I click on the command button. It is
on
the "strCmd = " line of code.

Oops, I made a small mistake. Try this:

strCmd = _
Q & SysCmd(acSysCmdAccessDir) & "\MSACCESS.EXE" & Q & _
" " & Q & strDB & Q & " /wrkgrp " & strWrkgrp & _
" /user Admin /pwd " & strPW
 
D

Dirk Goldgar

ADB_Seeker said:
I thought I had to have the square brackets when spaces were involved.

That's for references in queries. This a different thing -- you're building
a command line to be interpreted by Windows, and it wants quotes around
strings containing spaces.
Do I have to put in a specific password or will Access open the DB and
request a userid/password?

I believe it will ask you for a password; however, I'm not 100% sure. Try
it and see.
What do the "Qs" stand for?

That's a constant I defined for convenience higher up in the procedure, with
this line:

Const Q As String = """"

That gives it the value of a double-quote character (").
 
A

ADB_Seeker

Dirk, thank you for your help. I replaced the StrCmd code and am now getting
an error on the Set objSecuredDB... line. Following is what is returned.
Pop-up window1: Command line you used to start Microsoft Access contains an
option that Microsoft Access does not recognize. Exit and restart Microsoft
Access using valid command-line options.

when I click on OK, I get the following message:
Microsoft Access couldn't find file 'Secured':
This file is required for startup.

Pop-up window 2: Runtime error '-2147467259 (80004005)':

Automation error
unspecified error

Any ideas?
Thank you
 
D

Dirk Goldgar

ADB_Seeker said:
Dirk, thank you for your help. I replaced the StrCmd code and am now
getting
an error on the Set objSecuredDB... line. Following is what is returned.
Pop-up window1: Command line you used to start Microsoft Access contains
an
option that Microsoft Access does not recognize. Exit and restart
Microsoft
Access using valid command-line options.

when I click on OK, I get the following message:
Microsoft Access couldn't find file 'Secured':
This file is required for startup.

Pop-up window 2: Runtime error '-2147467259 (80004005)':

Automation error
unspecified error

Any ideas?

I didn't notice that your MDW file's name also contains a space. That means
it, too, must have quotes around it in the command string. Try this new
revised version:

strCmd = _
Q & SysCmd(acSysCmdAccessDir) & "\MSACCESS.EXE" & Q & _
" " & Q & strDB & Q & " /wrkgrp " & Q & strWrkgrp & Q & _
" /user Admin /pwd " & strPW

Also recall this note in my original post:
Note that you may need to specify full path for the workgroup file as well

If it still doesn't find the MDW file when you use the above command string,
you may need to include the full path in strWrkgrp.
 
A

ADB_Seeker

Oh, Yes. I remember you telling me that now. I put in the new strCmd = ...
AND I put in the full path for the secured DB and it works!!! Thank you!
 

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