ACC97: Function Called from Command Bar Control Executes 3 Times

Last reviewed: May 21, 1997
Article ID: Q162660
The information in this article applies to:
  • Microsoft Access 97

SYMPTOMS

Advanced: Requires expert coding, interoperability, and multiuser skills.

If you call a procedure in a form class module from the OnAction property of a command bar control in Microsoft Access 97, the function executes three times.

RESOLUTION

Store the procedure in a standard module instead of in a form's class module. When you call a procedure in a standard module in the OnAction property of a command bar control, the procedure executes only once.

STATUS

Microsoft has confirmed this to be a problem in Microsoft Access 97. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Open the sample database Northwind.mdb.

  2. Create a new form not based on any table or query in Design view called Form1.

  3. On the View menu, click Code.

  4. Type the following procedure:

          Function CmdBarTest()
    
             MsgBox "Running CmdBarTest()"
          End Function
    
    

  5. Save Form1, and then open it in Form view.

  6. On the View menu, point to Toolbars, and then click Customize.

  7. In the Toolbars dialog box, click New, and then name the toolbar ToolbarTest. Click OK.

  8. Click the Commands tab in the Customize dialog box, and then select Toolbox in the Categories box.

  9. Drag the Command Button from the Commands box to your empty Toolbar.

  10. Click Modify Selection in the Customize dialog box, and then click

        Properties.
    

  11. Type the following in the OnAction property:

           =Forms!Form1.CmdBarTest
    

  12. Click Close in the Control Properties dialog box, and then click Close

        in the Customize dialog box.
    

  13. With Form1 open in the background, click the command button on the

        ToolbarTest toolbar. Note that you receive the "Running CmdBarTest()"
        message box three times.
    

REFERENCES

For more information about running a Visual Basic function from a button on a custom toolbar, search the Help Index for "toolbar buttons, adding to toolbars," or ask the Microsoft Access 97 Office Assistant.


Additional query words: menu command bar tool class
Keywords : kbusage MdlProb PgmOthr
Version : 97
Platform : WINDOWS
Hardware : X86
Issue type : kbbug
Resolution Type : kbworkaround


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: May 21, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.