ACC: BeforeUpdate Macro Appears to Be Running Twice

ID: Q92810


The information in this article applies to:


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          : kbusage McrName 
Version           : 1.0 1.1 2.0 7.0 97
Platform          : WINDOWS 
Issue type        : kbprb 

Last Reviewed: March 12, 1999