ACC2002: MaxRecButton Property Setting Does Not Affect Maximum Records Command on the Records Menu (282370)
The information in this article applies to:
This article was previously published under Q282370 Moderate: Requires basic macro, coding, and interoperability skills.
This article applies only to a Microsoft Access project (.adp).
SYMPTOMS
The Maximum Records command on the Records menu of a form is not affected when you set the MaxRecButton property of a form. For example, when you set the MaxRecButton property of the form to No, the MaximumRecords command on the Records menu is still available.
CAUSE
The MaxRecButton property applies only to the navigation buttons on the form. It does not apply to the MaximumRecords command on the Records menu.
RESOLUTION
Use either one of the following methods to work around this behavior.
Create a Custom Menu for the Form
You can work around this behavior by creating a custom menu for the form that does not include the MaximumRecords command, and then setting the MenuBar property of the form in Design view to the name of your custom menu. For more information about creating a custom menu, click Microsoft Access Help on the Help menu, type how do I create a custom menu in the Office Assistant or the Answer Wizard, and then click Search to view the topic. For more information about attaching a custom menu to a form, click Microsoft Access Help on the Help menu, type how do I attach a menu to a form in the Office Assistant or the Answer Wizard, and then click Search to view the topic. Use Custom Visual Basic for Applications (VBA) Code to Disable the Maximum Records Command
You can either hide or disable the Maximum Records command by using the Microsoft Office CommandBar object model. Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.
The following example demonstrates how to hide the menu command when the form is activated, and how to show the menu command when the form is deactivated. - Open the sample project NorthwindCS.adp.
- Close the Main Switchboard form if it appears.
- On the View menu, point to Database Objects, and then click Forms.
- In the Database window, click the Customers form, and then click Design.
- On the View menu, click Code to view the module of the form.
- On the Tools menu, click References.
- Click to select the Microsoft Office 10.0 Object Library check box.
- Click OK to close the References dialog box.
- Add the following custom VBA code to the module of the form:
Private Sub Form_Activate()
Dim cBar As Office.CommandBar
Dim cBarCtl As Office.CommandBarControl
Set cBar = Application.CommandBars("Menu Bar")
Set cBarCtl = cBar.Controls("Records").Controls("Maximum Records...")
'Hide the Maximum Records menu command
cBarCtl.Visible = False
'Alternatively you could use this line to disable
'the command without hiding it
'cBarCtl.Enabled = False
Set cBarCtl = Nothing
Set cBar = Nothing
End Sub
Private Sub Form_Deactivate()
Dim cBar As Office.CommandBar
Dim cBarCtl As Office.CommandBarControl
Set cBar = Application.CommandBars("Menu Bar")
Set cBarCtl = cBar.Controls("Records").Controls("Maximum Records...")
'Show the Maximum Records menu command
cBarCtl.Visible = True
'Alternatively you could use this line to enable
'the command without hiding and showing it
'cBarCtl.Enabled = True
Set cBarCtl = Nothing
Set cBar = Nothing
End Sub
- On the File menu, click Close and Return to Microsoft Access.
- On the File menu, click Save, and then close the form.
- In the Database window, click the Customers form, and then click Open.
- Click the Records menu.
Note that the Maximum Records command on the Records menu is not available.
STATUSMicrosoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.
Modification Type: | Major | Last Reviewed: | 6/23/2005 |
---|
Keywords: | kbbug kbnofix KB282370 |
---|
|