ACC2002: MaxRecButton Property Setting Does Not Affect Maximum Records Command on the Records Menu (282370)



The information in this article applies to:

  • Microsoft Access 2002

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.
  1. Open the sample project NorthwindCS.adp.
  2. Close the Main Switchboard form if it appears.
  3. On the View menu, point to Database Objects, and then click Forms.
  4. In the Database window, click the Customers form, and then click Design.
  5. On the View menu, click Code to view the module of the form.
  6. On the Tools menu, click References.
  7. Click to select the Microsoft Office 10.0 Object Library check box.
  8. Click OK to close the References dialog box.
  9. 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
    
    					
  10. On the File menu, click Close and Return to Microsoft Access.
  11. On the File menu, click Save, and then close the form.
  12. In the Database window, click the Customers form, and then click Open.
  13. Click the Records menu.
Note that the Maximum Records command on the Records menu is not available.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce the Behavior

CAUTION: If you follow the steps in this example, you modify the sample Access project NorthwindCS.adp. You may want to back up the NorthwindCS.adp file and follow these steps on a copy of the project.

  1. Open the sample project NorthwindCS.adp.
  2. Close the Main Switchboard form if it appears.
  3. On the View menu, point to Database Objects, and then click Forms.
  4. In the Database window, click the Customers form, and then click Open.
  5. Note that the right-most navigation button at the bottom of the form is the Max Records button. The Max Records button has a caption that looks as follows: >|.... This button allows you to set the maximum number of records that are retrieved by the form.
  6. Click the Records menu. Note that it has a command that is named Maximum Records that also allows you to set the maximum number of records retrieved by the form.
  7. On the View menu, click Design View.
  8. On the View menu, click Properties to display the property sheet for the form.
  9. On the Other tab, set the MaxRecButton property to No.
  10. On the File menu, click Save, and then close the form.
  11. In the Database window, click the Customers form, and then click Open. Note that the Max Records navigation button is unavailable at the bottom of the form as expected.
  12. Click the Records menu.
Note that the Maximum Records command is still available, even though you set the MaxRecButton property of the form to No.

Modification Type:MajorLast Reviewed:6/23/2005
Keywords:kbbug kbnofix KB282370