ACC: Toggle Button with BeforeUpdate Set to CancelEvent

Last reviewed: May 27, 1997
Article 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 with the BeforeUpdate property set to a macro that performs the CancelEvent action behaves differently than a text box with 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 : FmsHowto kbusage
Version : 1.0 1.10 2.0 7.0 97
Platform : WINDOWS
Hardware : X86
Issue type : kbprb
Resolution Type : Info_Provided


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 27, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.