ACC: Toggle Button with BeforeUpdate Set to CancelEvent

ID: Q90142


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.

On a form, a toggle button that has its BeforeUpdate property set to a

macro that carries out the CancelEvent action behaves differently than a text box that has the same BeforeUpdate property setting.


CAUSE

Text boxes have a state in which they hold a Dirty value that cannot be saved or validated. This is why you can click a text box and, without making a change, move to another control.

Toggle buttons do not have a static state holding a Dirty value that cannot be validated. When the CancelEvent occurs, the button is left in its original, raised state. The button code does not consider the button to be dirty after the save failed. It has the original clean value.


STATUS

This behavior is by design.


MORE INFORMATION

Steps to Reproduce Behavior

The method outlined below uses the sample database Northwind.mdb (or NWIND.MDB versions 1.x or 2.0)
  1. Create a new form in Design view called ToggleTest based on the Products Table.


  2. Add a toggle button to the form and set the following properties:
    
          Toggle Button:
             ControlName: Discontinued
             ControlSource: Discontinued
             Before Update: CancelEvent Test 


  3. Add a text box to the form set the following properties:
    
          Text Box:
             ControlName: ProductName
             ControlSource: ProductName (or Product Name in versions 1.x and
                                         2.0)
             Before Update: CancelEvent Test 


  4. Create a new macro called CancelEvent Test with the following action:
    
          Macro Name            Action
          --------------------------------
          CancelEvent Test      CancelEvent 


  5. View the ToggleTest form in Form view. Click the toggle button, and then press TAB to move to the next control. Note that the record is dirtied and the toggle button does not appear sunken.


  6. Move to another record. Click in the text box, and then press TAB to move to another control. Note that the record is not dirtied.


Keywords : kbusage FmsHowto
Version : 1.0 1.10 2.0 7.0 97
Platform : WINDOWS
Issue type : kbprb


Last Reviewed: March 11, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.