Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2002

    Unanswered: Access Command Line Paramaters???

    Does Access have command line parameters so you could open a database to a specific object like a macro or module. I know you can open Excel to a specific page.

    If so what is the syntax?


  2. #2
    Join Date
    Dec 2001
    Here's something from one of our recent newsletters:

    6. Access Tips - Making Use of Command-Line Parameters
    Have you ever wanted to have a quick and easy way to bypass the startup form and get directly to the Access object you want to open or edit?

    How about scheduling a set of reports to print at a certain time?

    Or, have you ever wanted to have an easy way to open just the administration form that no other user has access to on their switchboard menu?

    With a command-line processor you can do this and more to greatly increase the utility and functionality of your database.

    The "Command" function, a batch file or shortcut, and a little code is all you need to get going. In the example database available here:

    ... you will see how we added the following code to the startup form OnOpen event procedure to see if a command line parm has been passed to our database:

    If Command = "" Then
    '* No command line parameters passed.
    '* There were parameters passed, so let's process them
    Exit Sub
    End If

    Then, the ng_ProcessCommandLine function parses all the command-line text after the "/cmd" command-line switch, looking for strings delimited by semi-colons. By passing a delimited string, you can provide any number of parameters to the command line processing function. The parsing works by calling the ever-useful xg_GetSubString function:

    '* Get individual parms from the command-line string
    strCLParm1 = xg_GetSubString(Command, 1, ";")
    strCLParm2 = xg_GetSubString(Command, 2, ";")
    strCLParm3 = xg_GetSubString(Command, 3, ";")
    strCLParm4 = xg_GetSubString(Command, 4, ";")
    strCLParm5 = xg_GetSubString(Command, 5, ";")

    Now, if we assume that the first parm, strCLParm1, contains a command that determines how the rest of the parameters will be processed, then we have a lot of flexibility. Ex.:

    Select Case strCLParm1
    Case "OpenReport"
    '* Open a report here
    Case "OpenForm"
    '* Open a form here
    Case "DoSomethingElse"
    '* Do something else here
    Case Else
    End Select

    You could put code here to open a set of weekly reports, to open a particular procedure in a module in design mode, or open a special administrator form.

    Then, to get this code to run, just specify the command-line in a shortcut or batch file that will cause the code to execute. Ex.:

    "C:\Program Files\Microsoft Office\Office\MSACCESS.EXE" "d:\My Documents\cl97.mdb" /cmd "OpenModule;MyModuleName;MyProcedureName"


    "C:\Program Files\Microsoft Office\Office\MSACCESS.EXE" "d:\My Documents\cl97.mdb" /cmd "OpenReport;rptCustomers;Preview"

    Once you have the shortcut text, you can use Windows Task Scheduler to execute Access with the command line at a specific time of day, week, or month.

    See the example database here: for more information, and for how to incorporate a command-line processor into your application.


    Hope this helps,
    Peter De Baets
    Peter's Software - Microsoft Access Tools for Developers

  3. #3
    Join Date
    Jul 2003

    Red face

    Hi Peter,

    Can you solve this problem ?

    When Access 2003 starts up, there are 2 dialog boxes :
    1. "Security warnings: Unsafe expressions are not blocked..."

    2. "Security warnings - This file may not be safe if contains code that was intended to harm your computer..."

    Do you know how to bypass them using Command Line Options ??

    Thank you very much in advance.

  4. #4
    Join Date
    Sep 2007
    hello Lepanto,

    I have the same problem. Just wonder if you have resolved this problem yet?


  5. #5
    Join Date
    Jul 2004
    South Dakota
    Don't really know of a good way to stop them but I know what is causing them. You need to change your Macro Security level settings to Low. Once you do that you won't get those annoying dialogs anymore.


  6. #6
    Join Date
    Sep 2007
    thank you canupus. I was hoping there is a way I can stop these annoying dialogs from my end.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts