ODE97: Print Command Not Available in Run-Time Applications
ID: Q173796
|
The information in this article applies to:
-
Microsoft Office Developer Edition 97
Moderate: Requires basic macro, coding, and interoperability skills.
SYMPTOMS
When you build a custom menu bar in Microsoft Access 97 and include the
built-in File menu, some commands do not appear on the menu in the run-time environment. For example, the Print command does not appear on the menu; as a result, you cannot modify the printer settings or properties.
CAUSE
Some menu commands, such as the Print command from the default File menu,
are disabled in the run-time environment.
RESOLUTION
Use either of the following two methods.
Method 1: Use the Command Bar Wizard
You can use the Command Bar Wizard to replace the default menu bar with a
custom menu bar. For more information about obtaining the Command Bar Wizard, please see the following article in the Microsoft Knowledge Base:
Q172300 ACC97: Command Bar Wizard Available in Download Center
Follow these steps to create a custom menu bar using the Command Bar
Wizard:
- Open your database in Microsoft Access 97.
- On the Tools menu, point to Add-ins, and then click Command Bar Wizard.
- Under Select Type in the Command Bar Wizard dialog box, click New, and then click Next.
- In the Select Template list, click Database, and then click Next.
- Click Next, and then type a name for the menu in the Menu Name box.
- Click Build.
NOTE: The Command Bar Wizard will create a new menu and close any
existing menus. You can dock the custom menu bar or move it to any
location on the screen.
- On the Tools menu, click Startup.
- In the Startup dialog box, type or select your menu in the Menu Bar box.
- Click OK.
Note that the Print command is available when you open this database in the
run-time environment, either by running a Microsoft Access application
installed from disk images created with the Microsoft Office 97 Developer
Edition or by running Microsoft Access using the /runtime switch. When you click Print, the Print dialog box appears.
Method 2: Call a Custom Print Function
You can create a Microsoft Visual Basic for Applications function that
displays the Print dialog box and attach that function to a custom Menu Bar. To do so, follow these steps:
- Open your database in Microsoft Access 97.
- In the Database window, click the Modules tab, and then click New.
- Type the following code in the module that you just created:
Public Function PrintOut()
' Attached to a custom Print command on a custom menu bar.
' Use the RunCommand method to display the print dialog box.
On Error GoTo ErrorTrap
DoCmd.RunCommand acCmdPrint
Exit Function
ErrorTrap:
' Check whether the RunCommand method was canceled.
' If RunCommand is canceled, it generates a trappable
' run-time error (2501).
If Err.Number = 2501 Then
Exit Function
Else
MsgBox Err.Number & vbCRLF & Err.Description
End If
End Function
- On the Debug menu, click Compile Loaded Modules.
- Save the module as basPrintFunction.
Follow these steps to create the custom menu bar:
- On the View menu, point to Toolbars, and then click Customize.
- Click the Toolbars tab, and then click New.
- In the New Toolbar dialog box, type a name in the Toolbar name box, and then click OK.
- In the Customize dialog box, click Properties.
- In the Toolbar Properties dialog box, click Menu Bar in the Type list, and then click Close.
- In the Customize dialog box, click the Commands tab, and then click New Menu in the Categories list.
- Drag New Menu from the Commands box to your custom menu bar.
- On your custom menu bar, right-click New Menu and type a name for the menu in the Name box. Press ENTER.
- In the Customize dialog box, click File in the Categories box, and drag Custom from the Commands box to your new menu.
NOTE: When you drag the Custom command over the name of your new menu, it will create a blank menu. It is on this blank menu that you
should place the Custom command.
- On your custom menu bar, right-click the Custom command from step 9 and type a command name, such as Print, in the Name box, and then click Properties.
- In the <menu name> Control Properties dialog box, type =PrintOut() in the On Action box, and then click Close.
- Add any additional menu commands that you need in the same manner.
- In the Customize dialog box, click Close.
- On the Tools menu, click Startup.
- In the Startup dialog box, type or select your menu in the Menu Bar box.
- Click OK.
When you open your database in the run-time environment, either by running
a Microsoft Access application installed from disk images created with the
Microsoft Office 97 Developer Edition Tools or by running Microsoft Access
using the /runtime switch, note that the Print command is now available. When you click Print, the Print dialog box appears.
MORE INFORMATIONWARNING: The following steps change the StartUpMenuBar property of the Northwind sample database. You may want to back up the Northwind.mdb file and perform these steps on a copy of the database.
Steps To Reproduce Behavior
- Start Microsoft Access 97 and open the sample database Northwind.mdb.
- On the View menu, point to Toolbars, and then click Customize.
- In the Customize dialog box, click the Toolbars tab, and then click New.
- In the New Toolbar dialog box, type a name in the Toolbar Name box, and then click OK.
- In the Toolbars list, click the new toolbar, and then click Properties.
- In the Toolbar Properties dialog box, click Menu Bar in the Type list, and then click Close.
- In the Customize dialog box, click the Commands tab.
- In the Categories list, click Built-in Menus.
- Drag the File Menu from the Commands box, to the toolbar created in step 4.
- In the Customize dialog box, click Close.
- On the Tools menu, click Startup.
- In the Startup dialog box, type or select your custom toolbar in the Menu Bar box, and then click OK.
- Quit Microsoft Access and restart Northwind using the /runtime switch.
For example, click Start on the taskbar, and then click Run. In the Open box, type the following command on a single line:
"c:\Program Files\Microsoft Office\Office\msaccess.exe"
"c:\Program Files\Microsoft Office\Office\Samples\Northwind.mdb"
/runtime
Note that the custom menu bar appears when Northwind opens, but it does
not show the Print command.
REFERENCES
For more information about changes in the run-time environment, search the
Microsoft ODE Tools Help Index for "disabled" or "disabled features in run-
time environment."
For additional information about differences between the retail and run-
time versions of Microsoft Access, please see the following article in the
Microsoft Knowledge Base:
Q162521 ACC97: Differences Between Retail and Run-Time Microsoft Access
For additional information about getting help with Visual Basic for
Applications, please see the following article in the Microsoft Knowledge
Base:
Q163435
VBA: Programming Resources for Visual Basic for Applications
Additional query words:
prb print dialog menubar runtime
Keywords : kbdta
Version : WINDOWS:97
Platform : WINDOWS
Issue type : kbhowto kbprb kbinfo
|