Microsoft KB Archive/100134

From BetaArchive Wiki

Article ID: 100134

Article Last Modified on 1/18/2007



APPLIES TO

  • Microsoft Access 1.0 Standard Edition
  • Microsoft Access 1.1 Standard Edition
  • Microsoft Access 2.0 Standard Edition
  • Microsoft Access 95 Standard Edition
  • Microsoft Access 97 Standard Edition



This article was previously published under Q100134

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

SYMPTOMS

The macro or function attached to the BeforeUpdate or AfterUpdate property of a bound control does not run when expected.

CAUSE

The BeforeUpdate and AfterUpdate events of a bound control will not be triggered if the bound control was modified by a macro or by code.

RESOLUTION

You can work around this behavior by causing the macro or code that modifies the bound control to manually trigger the event pointed to by the BeforeUpdate or AfterUpdate property of the bound control.

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 control'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 control'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: kbprb kbusage KB100134