Command() Function to get command line parameter not working

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to use the Command function to pass a paramter into Access and it
isn't working. If the parameter is "auto" I want to call a macro to print a
bunch of reports, otherwise I want to display a form.

The Icon is setup as "S:\admin\excel queries.mdb" /cmd "auto"

I have in the only module, and have the AutoExec Macro call it:

Public Function CheckCommandLine()

' Check the value returned by Command function and display
' the appropriate form.

MsgBox Command() ' for debug purposes

If Command = "auto" Then
DoCmd.RunMacro "mcrPrintReports1"
Else
DoCmd.OpenForm "Form1"
End If

End Function

But the msgbox shows up empty and it always just runs the form.
Help!
 
hi Mike,
The Icon is setup as "S:\admin\excel queries.mdb" /cmd "auto"
You need to specify the Access executable, cause otherwise the shell
handler, which is not aware of command options, is invoked:

"C:\Path\MSACCESS.EXE" "C:\Path\.MDB" /cmd "auto"


mfG
--> stefan <--
 
Include the path to msaccess.exe in the shortcut, e.g.:

"C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE"
"S:\admin\excel queries.mdb" /cmd auto
 
Back
Top