ACC: How to Open MS Access to a Specific Form Using a Shortcut

Last reviewed: December 11, 1997
Article ID: Q177475
The information in this article applies to:
  • Microsoft Access versions 7.0, 97

SUMMARY

Moderate: Requires basic macro, coding, and interoperability skills.

This article describes how you can create two types of shortcuts on the Windows 95 desktop that will start Microsoft Access and open a form of your choosing. You can create such a shortcut either by dragging the form from the Database window to the desktop or by using the /cmd command-line switch.

MORE INFORMATION

Method 1

You can drag a form from the Database window directly to the desktop. To do so, follow these steps:

  1. Open the sample database Northwind.mdb.

  2. Select the Customers form in the Database window.

  3. Restore and position Microsoft Access so you can see the desktop as well as Microsoft Access.

  4. Drag the Customers form to the desktop. Note that you now have a shortcut on your desktop named "Shortcut to Customers in Northwind."

  5. Close Microsoft Access.

  6. Double-click the shortcut on the desktop. Note that Microsoft Access starts with the Customers form of the sample database Northwind.mdb open.

Method 2

The following example shows how you can create two shortcuts that will start Microsoft Access and open either the Orders or the Employees form.

  1. Right-click the Windows 95 desktop, point to New on the menu that appears, and then click Shortcut.

  2. In the Create Shortcut dialog box, create the following two shortcuts (one at a time) with the following command-lines:

    NOTE: In the following sample, an underscore (_) at the end of a line is used as a line-continuation character. Remove the underscore from the end of the line when re-creating this sample.

          C:\Program Files\Microsoft Office\Office\Msaccess.exe _
          C:\Program Files\Microsoft Office\Office\Samples\Northwind.mdb _
          /cmd "Orders"
    

          C:\Program Files\Microsoft Office\Office\Msaccess.exe _
          C:\Program Files\Microsoft Office\Office\Samples\Northwind.mdb _
          /cmd "Employees"
    

    NOTE: These shortcuts assume that Microsoft Access is installed in the C:\Program Files\Microsoft Office\Office\ folder.

  3. Open the sample database Northwind.mdb and create the following function in a new module:

        Function CheckCommandLine()
          ' Check value returned by Command function.
          If Command = "Orders" Then
    
             DoCmd.OpenForm "Orders"
          ElseIf Command = "Employees" Then
             DoCmd.OpenForm "Employees"
          Else
             Exit Function
          End If
        End Function
    
    

  4. Create a new macro as follows and save it as AutoExec.

          Action
          -------
          RunCode
    

          AutoExec Actions
          -----------------------------------
          RunCode
    
             Function Name: CheckCommandLine()
    
    

  5. Close Microsoft Access. On the desktop, double-click the first shortcut. Note that Microsoft Access starts with the Orders form of the sample database Northwind.mdb open.

  6. Close Microsoft Access. On the desktop, double-click the second shortcut. Note that Microsoft Access starts with the Employees form of the sample database Northwind.mdb open.

If you go to the Tools menu, click Options, and then look on the Advanced tab, you will see the /cmd value in the Command-Line Arguments field.

REFERENCES

For more information about command-line switches, search the Help Index for "command-line."


Additional query words: shortcut short cut making creating
Keywords : FmsOthr
Version : WINDOWS:2.0,7.0,97
Platform : WINDOWS
Hardware : x86
Issue type : kbhowto


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: December 11, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.