ACC1x: How to Disable the Menu Bar When Previewing a ReportID: Q102524
|
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.
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:
'******************************************************************
'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
"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
Last Reviewed: March 25, 1999