ACC: BeforeUpdate Macro Appears to Be Running Twice

Last reviewed: August 6, 1997
Article ID: Q92810
The information in this article applies to:
  • Microsoft Access versions 1.0, 1.1, 2.0, 7.0, 97

SYMPTOMS

Novice: Requires knowledge of the user interface on single-user computers.

The BeforeUpdate macro appears to be running twice rather than only once.

CAUSE

The BeforeUpdate macro will run whenever an edited record is saved. And if you add records using the Paste Append command, it will run when each of those records is added. If you find that the BeforeUpdate macro is running more than once, check to see exactly what actions you are taking.

STATUS

This behavior is by design.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Create a macro with a MsgBox action and a CancelEvent action.

  2. Save this macro as Macro1.

  3. Create a form based on any table and add a text box.

  4. Set the form's BeforeUpdate property to the Macro1 macro.

  5. View the form in Form view.

  6. Enter data in a field, and then select the data in that field.

  7. On the Edit menu, click Copy.

  8. On the Edit menu, click Paste Append.

  9. Click OK when the Message box (that you created in the Macro1 macro) appears.

  10. Close the form.

  11. Click OK when the Message box (that you created in the Macro1 macro) appears.

  12. Click OK when the following error message appears.

    In Microsoft Access 7.0 and 97:

    You can't save this object at this time. Microsoft Access may have encountered an error while trying to save a record. If you close the object now, the changes you made will be lost. Do you want to close the database object anyway?

    In Microsoft Access versions 1.x and 2.0:

    The record being edited can't be saved. If you close the form, the changes you've made to the record will be lost. Close anyway?

Note that the message box you created in Macro1 reappeared in step 11. The macro that you assigned to the BeforeUpdate property is running twice: once when the record that you added using the Paste Append command is saved, and twice when the edited record is saved.

REFERENCES

For more information about form event properties, search the Help Index for "Events" and then select "Find out when events occur," or ask the Microsoft Access 97 Office Assistant.

For more information about form event properties, search the Help Index for "BeforeUpdate, AfterUpdate Properties," or ask the Microsoft Access 97 Office Assistant.

Keywords          : McrName kbusage
Version           : 1.0 1.1 2.0 7.0 97
Platform          : WINDOWS
Hardware          : x86
Issue type        : kbprb
Solution 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: August 6, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.