access command line parameters

G

Guest

Hi, I need to be able to launch an Access 2000 application with command line parameters to have some startup info preselected. According to the documentation, I should be able to include /cmd and a parameter on the command line, and then read the value using the Command function. However, I can't get it to work. Here are the details

I'm launching the app from Start,Run as follows: c:\temp\mydb.mdb /cmd "Ken" (I've tried various combinations of forward slash, back slash, quotes, no quotes, etc with no effect)

Mydb.mdb has a startup form with the following code

Private Sub Form_Open(Cancel As Integer
If Command = "Ken" The
MsgBox "got it
Els
MsgBox "no good
End I
End Su

Ideally I would like to assign the parameter to a variable to take subsequent action, but for now I can't even get this simple exampe to work.

Appreciate any suggestions

Thanks, Ken
 
B

Bryan Reich [MSFT]

You are launching Access indirectly by asking the OS to load an .mdb file,
which the OS does by building it's own Access command line, but the OS only
uses the document you have provided and drops the remainder of that line.
Instead, run a command line like this:

<MSACCESS PATH>\msaccess.exe "C:\temp\mydb.mdb" /cmd "Ken"

This will ensure that the access executable is receiving the command line
exactly as you specify it, including the /cmd parameter.
--
Bryan Reich
Microsoft Office
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of any included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


Ken said:
Hi, I need to be able to launch an Access 2000 application with command
line parameters to have some startup info preselected. According to the
documentation, I should be able to include /cmd and a parameter on the
command line, and then read the value using the Command function. However,
I can't get it to work. Here are the details:
I'm launching the app from Start,Run as follows: c:\temp\mydb.mdb /cmd
"Ken" (I've tried various combinations of forward slash, back slash,
quotes, no quotes, etc with no effect).
Mydb.mdb has a startup form with the following code:

Private Sub Form_Open(Cancel As Integer)
If Command = "Ken" Then
MsgBox "got it"
Else
MsgBox "no good"
End If
End Sub

Ideally I would like to assign the parameter to a variable to take
subsequent action, but for now I can't even get this simple exampe to work.
 

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