ACC97: Function Called from Command Bar Control Executes 3 Times
ID: Q162660
|
The information in this article applies to:
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, the function runs 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 runs only once.
STATUS
Microsoft has confirmed this to be a problem in Microsoft Access 97.
MORE INFORMATION
Steps to Reproduce Behavior
- Open the sample database Northwind.mdb.
- Create a new form not based on any table or query in Design view called
Form1.
- On the View menu, click Code.
- Type the following procedure:
Function CmdBarTest()
MsgBox "Running CmdBarTest()"
End Function
- Save Form1, and then open it in Form view.
- On the View menu, point to Toolbars, and then click Customize.
- In the Toolbars dialog box, click New, and then name the toolbar
ToolbarTest. Click OK.
- Click the Commands tab in the Customize dialog box, and then select
Toolbox in the Categories box.
- Drag the Command Button from the Commands box to your empty Toolbar.
- Click Modify Selection in the Customize dialog box, and then click
Properties.
- Type the following in the OnAction property:
=Forms!Form1.CmdBarTest
- Click Close in the Control Properties dialog box, and then click Close
in the Customize dialog box.
- 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
Version : 97
Platform : WINDOWS
Issue type : kbbug