ACC2000: BeforeUpdate and AfterUpdate Properties Not Working

ID: Q201088


The information in this article applies to:

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

This article applies to a Microsoft Access database (.mdb) and a Microsoft Access project (.adp).


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 are not triggered if the bound control is first 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.


MORE INFORMATION

Steps to Reproduce Behavior

  1. Open the sample database Northwind.mdb.


  2. Create the following macro called TestCityForNull:


  3. 
       Macro Name       Condition        Action
       ---------------------------------------------
       TestCityForNull  IsNull([City])   MsgBox
                        ...              CancelEvent
    
    
       TestCityForNull Action Arguments
       ----------------------------------
       MsgBox:
       Message: City Is A Required Field! 
  4. Create the following macro called SetCityToNull:


  5. 
       Macro Name        Action
       ------------------------------
       SetCityToNull   OpenForm
                       SetValue
    
    
       SetCityToNull Action Arguments
       -------------------------------
       OpenForm Action:
       FormName: Customers
       View: Form
    
       SetValue Action:
       Item:[Forms]![Customers]![City]
       Expression: Null 
  6. Open the Customers form in Design view and select the TestCityForNull macro in the City control's BeforeUpdate property.


  7. 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.


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


  9. City Is A Required Field!
  10. Do not save changes when you close the Customers form.



REFERENCES

For more information about on event procedures, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type "event procedures" in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

Additional query words: before after update ui prb


Keywords          : kbusage kbdta FmsEvnt 
Version           : WINDOWS:2000
Platform          : WINDOWS 
Issue type        : kbprb 

Last Reviewed: May 13, 1999