This article was previously published under Q177475
This article has been archived. It is offered "as is" and will no longer be updated.
Moderate: Requires basic macro, coding, and interoperability skills.
This article describes how you can create two types of shortcuts on theWindows 95 or later desktop, both of which will start Microsoft Access andopen to a form of your choosing. You can create such a shortcut either bydragging the form from the Database window to the desktop or by using the/cmd command-line switch.
You can drag a form from the Database window directly to the desktop. To doso, follow these steps:
Open the sample database Northwind.mdb.
Select the Customers form in the Database window.
Restore and position Microsoft Access so that you can see the desktop as well as Microsoft Access.
Drag the Customers form to the desktop. Note that you now have a shortcut on your desktop named "Shortcut to Customers in Northwind."
Close Microsoft Access.
Double-click the shortcut on the desktop. Note that Microsoft Access starts with the Customers form of the sample database Northwind.mdb open.
The following example shows how you can create two shortcuts that willstart Microsoft Access and open either the Orders or the Employees form.
Right-click the Windows 95 or later desktop, point to New on the menu that appears, and then click Shortcut.
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.
NOTE: These shortcuts assume that Microsoft Access is installed in the C:\Program Files\Microsoft Office\Office\ folder.
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
Create a new macro as follows and save it as AutoExec.
Action ------- RunCode AutoExec Actions ----------------------------------- RunCode Function Name: CheckCommandLine()
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.
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 Advancedtab, you will see the /cmd value in the Command-Line Arguments field.
For more information about command-line switches, search the Help Index for"command-line."