Home  |   French  |   About  |   Search  | mvps.org  

What's New
Table Of Contents
Credits
Netiquette
10 Commandments 
Bugs
Tables
Queries
Forms
Reports
Modules
APIs
Strings
Date/Time
General
Downloads
Resources
Search
Feedback
mvps.org

In Memoriam

Terms of Use


VB Petition

Bugs: Function Called from Command Bar Control Executes 3 Times

Author(s)
Albert D. Kallal
 BUG: Function Called from Command Bar Control Executes 3 Times

http://support.microsoft.com?id=162660

If you use a custom menu bar, and call a code routine in the active form, then the code will run 3 times.
This bug exists in Access97, Access2000, and Access2002.

The suggested solution in the above KB article is to move the code out of the forms module and into a standard code module.

For example if your open form is called myForm, and you wanted to call some function code in your forms module, then you should be able to use the following expression in the "on action" for your custom menu bar:

=([forms]![myForm].DeleteRec())

The above example would call a function called "DeleteRec". Note that you MUST declare the function as public in the forms module for the above to work.

However, the above is NOT workable due to the bug that will call the code 3 times.

If you remove the forms qualify, then you get:

=DeleteRec()

Using the above expression in your menu bar "on action" to run the code is shorter, and it also fixes the "3 times" bug.

Don’t qualify the forms reference in the menu bar, and your code will not run 3 times.
 

© 1998-2010, Dev Ashish & Arvin Meyer, All rights reserved. Optimized for Microsoft Internet Explorer