ACC1x: How to Disable the Menu Bar When Previewing a Report
ID: Q102524
|
The information in this article applies to:
-
Microsoft Access versions 1.0, 1.1, 2.0
SUMMARY
Although you can display a custom menu bar in a form in Microsoft Access
version 1.x, there is no way to display a custom menu bar when previewing a
report. However, you can completely remove the menu bar when previewing a
report using Microsoft Windows API calls. This article demonstrates a
sample Access Basic function that you can use to remove the menu bar when
previewing a report.
Microsoft Access version 2.0 has built-in functionality to create a custom
menu for a report. For more information about creating custom menus, search
for "custom menus" using the Microsoft Access 2.0 Help menu.
MORE INFORMATION
The technique presented in this article removes the menu bar when in
Print Preview. To also remove the toolbar, choose Options from the
View menu and set Show Toolbar to No.
The Access Basic code below needs to be called for each report every time
you switch to Print Preview. If you display another report after calling
this code, Microsoft Access will re-establish the Print Preview menu.
NOTE: The menu for the report is also re-established if switching from
the report to a form and then back to the report. If the window from
which the report is called is maximized, then the display may become
erratic. Symptoms of an erratic display include duplications of the
Control menu icon and the Min/Max icons before the report appears.
To remove the menu bar that appears when you are printing a report,
use the following steps:
- Create the new module below.
NOTE: In the following sample code, an underscore (_) is used as a line-
continuation character. Remove the underscore when re-creating this code
in Access Basic.
NOTE: You may have some Microsoft Windows API functions defined in an
existing Microsoft Access library; therefore, your declarations may be
duplicates. If you receive a duplicate procedure name error message,
remove or comment out the declarations statement in your code.
'******************************************************************
'Declarations section of the module
'******************************************************************
Option Explicit
Declare Function FindWindow% Lib "user" (ByVal lpClassName As Any, _
ByVal lpCaption As Any)
Declare Function SetMenu% Lib "User" (ByVal hWnd%, ByVal hMenu%)
'==================================================================
'The following function removes the Microsoft Access menu bar by:
' - Retrieving the Microsoft Access window handle with FindWindow.
' - Removing the Microsoft Access menu bar with SetMenu.
'==================================================================
Function RemoveAccessMenu ()
Dim hWnd%, dummy%
hWnd% = FindWindow("OMain", 0&)
dummy% = SetMenu(hWnd%, 0)
End Function
- In the report in which you want to disable the menu bar, set the
OnFormat or OnPrint property of the first section that prints (such
as the Report Header section) to call the RemoveAccessMenu()
function:
OnFormat: =RemoveAccessMenu()
REFERENCES
"Programmer's Reference Library: Microsoft Windows 3.1 Guide to
Programming Reference," Volumes 1-6, Microsoft Press, 1992
Additional query words:
menubar security
Keywords : kbusage RptOthr
Version : 1.0 1.1
Platform : WINDOWS
Issue type : kbhowto