ACC: BeforeUpdate and AfterUpdate Field Properties Not Working

Last reviewed: May 28, 1997
Article ID: Q100134
The information in this article applies to:
  • Microsoft Access versions 1.0, 1.1, 2.0, 7.0, 97

SYMPTOMS

Moderate: Requires basic macro, coding, and interoperability skills.

The macro or function attached to a field's BeforeUpdate or AfterUpdate property does not run when expected.

CAUSE

A field's BeforeUpdate and AfterUpdate events will not be triggered if the field was modified by a macro or by code.

RESOLUTION

You can work around this behavior by causing the macro or code that modifies the field to manually trigger the event pointed to by the field's BeforeUpdate or AfterUpdate property.

STATUS

This behavior is by design.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Open the sample database Northwind.mdb (or NWIND.MDB in Microsoft Access 2.0 or earlier).

  2. Create the following macro called TestCityForNull:

         Macro Name       Condition        Action
         ----------------------------------------
         TestCityForNull  IsNull([City])   MsgBox
                          ...              CancelEvent
    
         TestCityForNull Actions
         -------------------------------------
         MsgBox:
            Message: City Is A Required Field!
    
    

  3. Create the following macro called SetCityToNull:

           Macro Name      Action
           --------------------
           SetCityToNull   OpenForm
                           SetValue
    
           SetCityToNull Actions
           ---------------------
           OpenForm Action:
              FormName: Customers
              View: Form
    
           SetValue Action:
              Item:[Forms]![Customers]![City]
              Expression: Null
    
    

  4. Open the Customers form in Design view and select the TestCityForNull macro in the City field's BeforeUpdate property.

  5. Run the SetCityToNull macro. Note that it successfully blanks out the City field (you can press ESC twice to get it back). If the field's BeforeUpdate event had been triggered, the TestCityForNull macro would not have allowed the field to be blank.

  6. Try to blank out the City field manually. The TestCityForNull macro will be triggered, displaying the following message:

          City Is A Required Field!
    

  7. Do not save changes when you close the Customers form.

REFERENCES

For more information about the order of event properties, search for "Event procedures," and then "order of events" using the Microsoft Access 97 Help Index.


Additional query words: before after update ui
Keywords : FmsEvnt kbusage
Version : 1.0 1.1 2.0 7.0 97
Platform : WINDOWS
Hardware : X86
Issue type : kbprb
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 28, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.