Microsoft KB Archive/96113

{|
 * width="100%"|

PRB: RunCode Macro May Not Evaluate Conditions
'Article ID: Q96113

Creation Date: 08-MAR-1993

Revision Date: 19-SEP-1996' The information in this article applies to:


 * Microsoft Access versions 1.0 and 1.1

SYMPTOMS

If you execute a RunCode macro with a condition that evaluates a control on a form, it runs the code specified regardless of whether the condition is met.

CAUSE

This will happen if the function specified in the action argument is preceded by an equal sign (=).

RESOLUTION

The macro action argument requires only the name of the Access Basic function procedure to execute and does not require an equal sign before the function name.

STATUS

This behavior no longer occurs in Microsoft Access version 2.0.

MORE INFORMATION

Steps to Reproduce Behavior

 Create an unbound form with two unbound text box controls named Field1 and Field2. Save the form as Form1.  In a new module, create the following sample function: '****************************************************     'Declaration section of the module '****************************************************     Option Explicit Function TestFunction MsgBox &quot;Test&quot; End Function   Create the following new macro, and then save it as Test1: Macro Name  Condition                  Action ---     Test1        Forms![Form1]![Field1]=2   RunCode Test1 Actions -     RunCode Function Name: =TestFunction  Open Form1 in Design view. Assign the Test1 macro to Field1's OnExit property. View the form in Form view. Enter &quot;1&quot; (without quotation marks) in Field1 and then press the TAB key. Note that the message box appears even though the condition in the macro was not met.
 * }

-

"THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED &quot;AS IS&quot; 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." '' ©1997 Microsoft Corporation. All rights reserved. Legal Notices.

''

Additional reference words: 1.00 1.10 function condition ignored

KBCategory: kbusage

KBSubcategory: McrActn