passing parameters using /cmd

  • Thread starter karen scheu via AccessMonster.com
  • Start date
K

karen scheu via AccessMonster.com

I am having a hard time finding out how to pass in a parameter using /cmd. I
need to pass the Path of the clients FE on a command line that is opening an
access mdb that will eventually push down a new mdb.

strOpenClient = "MSAccess.exe " "Update.mdb" /cmd.....
Shell strOpenClient, vbNormalFocus

The update.mdb opens a form with a timer event that should make a backup of
client app, delete client app, then copy the system app to the client's
proper directory. I need to pass in the client path when the client FE
executes the above shell command.

I would appreciate any help on this.

Thanks,
Karen
 
M

M.L. Sco Scofield

First, my apologies to everyone for converting this message to RTF. There is a long line in the code that got ugly when it wrapped.

Karen,

This is a classic problem of needing quotes for VBA as delimiters and literal quotes in the command line.

Paste this into a code module in a database:
(You may need to fix the path if your copy of Northwind is in another directory)

'~~~~~~~~~~~~~~~~~~~~~~~~~~~
Public Sub ShellTest()

Dim strCommandline As String

strCommandline = """msaccess.exe"" " & _
"""C:\Program Files\Microsoft Office 2003\OFFICE11\SAMPLES\Northwind.mdb"" " & _
"/cmd ""Command Test"""

Shell strCommandline

End Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~~

When the second copy of Access starts with Northwind loaded, open up a VBA window from there. Open the Immediate window and enter:

?command

You should see Command Test echoed in the Immediate window.

To see the actual line passed to the shell command, single step to or set a break point on the Shell line. Go to the immediate window and enter:

?strCommandline

This will echo back the command line without the quotes that were used as delimiters by VBA.

Good luck.

Sco

M.L. "Sco" Scofield, Microsoft Access MVP, MCSD, MCP, MSS, A+
Denver Area Access Users Group Vice President www.DAAUG.org
MS Colorado Events Administrator www.MSColoradoEvents.com
Useful Metric Conversion #18 of 19: 8 nickels = 2 paradigms (My personal favorite)
Miscellaneous Access and VB "stuff" at www.ScoBiz.com
 
K

karen via AccessMonster.com

Thank You so much for the help. I tried your example and it worked.

Karen

M.L. Sco Scofield said:
First, my apologies to everyone for converting this message to RTF. There is a long line in the code that got ugly when it wrapped.

Karen,

This is a classic problem of needing quotes for VBA as delimiters and literal quotes in the command line.

Paste this into a code module in a database:
(You may need to fix the path if your copy of Northwind is in another directory)

'~~~~~~~~~~~~~~~~~~~~~~~~~~~
Public Sub ShellTest()

Dim strCommandline As String

strCommandline = """msaccess.exe"" " & _
"""C:\Program Files\Microsoft Office 2003\OFFICE11\SAMPLES\Northwind.mdb"" " & _
"/cmd ""Command Test"""

Shell strCommandline

End Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~~

When the second copy of Access starts with Northwind loaded, open up a VBA window from there. Open the Immediate window and enter:

?command

You should see Command Test echoed in the Immediate window.

To see the actual line passed to the shell command, single step to or set a break point on the Shell line. Go to the immediate window and enter:

?strCommandline

This will echo back the command line without the quotes that were used as delimiters by VBA.

Good luck.

Sco

M.L. "Sco" Scofield, Microsoft Access MVP, MCSD, MCP, MSS, A+
Denver Area Access Users Group Vice President www.DAAUG.org
MS Colorado Events Administrator www.MSColoradoEvents.com
Useful Metric Conversion #18 of 19: 8 nickels = 2 paradigms (My personal favorite)
Miscellaneous Access and VB "stuff" at www.ScoBiz.com
I am having a hard time finding out how to pass in a parameter using /cmd. I
need to pass the Path of the clients FE on a command line that is opening an
[quoted text clipped - 12 lines]
Thanks,
Karen
 
M

M.L. Sco Scofield

You're welcome. Glad it worked.

Sco

M.L. "Sco" Scofield, Microsoft Access MVP, MCSD, MCP, MSS, A+
Denver Area Access Users Group Vice President www.DAAUG.org
MS Colorado Events Administrator www.MSColoradoEvents.com
Useful Metric Conversion #18 of 19: 8 nickels = 2 paradigms (My personal
favorite)
Miscellaneous Access and VB "stuff" at www.ScoBiz.com


karen via AccessMonster.com said:
Thank You so much for the help. I tried your example and it worked.

Karen

M.L. Sco Scofield said:
First, my apologies to everyone for converting this message to RTF. There is a long line in the code that got ugly when it wrapped.

Karen,

This is a classic problem of needing quotes for VBA as delimiters and literal quotes in the command line.

Paste this into a code module in a database:
(You may need to fix the path if your copy of Northwind is in another directory)

'~~~~~~~~~~~~~~~~~~~~~~~~~~~
Public Sub ShellTest()

Dim strCommandline As String

strCommandline = """msaccess.exe"" " & _
"""C:\Program Files\Microsoft Office 2003\OFFICE11\SAMPLES\Northwind.mdb"" " & _
"/cmd ""Command Test"""

Shell strCommandline

End Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~~

When the second copy of Access starts with Northwind loaded, open up a VBA window from there. Open the Immediate window and enter:

?command

You should see Command Test echoed in the Immediate window.

To see the actual line passed to the shell command, single step to or set a break point on the Shell line. Go to the immediate window and enter:

?strCommandline

This will echo back the command line without the quotes that were used as delimiters by VBA.

Good luck.

Sco

M.L. "Sco" Scofield, Microsoft Access MVP, MCSD, MCP, MSS, A+
Denver Area Access Users Group Vice President www.DAAUG.org
MS Colorado Events Administrator www.MSColoradoEvents.com
Useful Metric Conversion #18 of 19: 8 nickels = 2 paradigms (My personal favorite)
Miscellaneous Access and VB "stuff" at www.ScoBiz.com
I am having a hard time finding out how to pass in a parameter using /cmd. I
need to pass the Path of the clients FE on a command line that is
opening an
[quoted text clipped - 12 lines]
Thanks,
Karen

--
Thank You ! I am using only the database name.


Message posted via AccessMonster.com
 

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