ACC2000: AutoRepeat Is Disabled When Macros Change the Focus (209669)



The information in this article applies to:

  • Microsoft Access 2000

This article was previously published under Q209669
Novice: Requires knowledge of the user interface on single-user computers.

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

SYMPTOMS

The AutoRepeat property for command buttons does not work in conjunction with the GoToRecord/Next macro action for moving to successive records on a form. In other words, if your form uses command buttons instead of the record selector buttons to move from record to record, the AutoRepeat property does not repeatedly run a macro that performs a GoToRecord/Next action.

Also, the AutoRepeat property fails under the same circumstances when you use the DoMenuItem/Form/Records/GoTo/Next macro action. To rerun the macro, you must click the command button again.

CAUSE

This is correct behavior for these macro actions. The following two points need clarification before the cause can be properly explained:
  • OnClick Property: The macro assigned to the OnClick property of a command button normally does not run until you click and let up the command button with the mouse pointer in the command button's region. The exception is when the command button's AutoRepeat property is set to Yes. In this case, the macro set for the OnClick property of the command button runs when the button is clicked and held down with the mouse pointer in the command button's region. The macro runs repeatedly as long as the button is held down.
  • Focus: Several macro actions change the focus on the form. For example, GoToControl, GoToRecord, OpenForm, OpenTable, and ApplyFilter all change the focus. Therefore, if a command button's OnClick property macro changes the focus on the form, for example, to the next record, the command button loses the focus until it is clicked again.

    That is, when you hold down a command button with the button's AutoRepeat property set to Yes, and the macro changes the form's focus, your action (holding down the button) does not cause the macro to run again. You have to click the command button again. The button may even appear to still be held down, even after you have released the mouse button, but the macro does not run continuously.

MORE INFORMATION

Steps to Reproduce Behavior

CAUTION: If you follow the steps in this example, you modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and follow these steps on a copy of the database.

  1. Start Microsoft Access and open the sample database Northwind.mdb.
  2. Create a new macro as follows and save it as AutoRepeatTest:

    Macro: AutoRepeatTest
    Action: GoToRecord

    Action Arguments
    Object Type: Form
    Object Name: Customers
    Record: Next

  3. Open the Customers form in Design view.
  4. From the Database window, drag the macro you have just created onto the form to automatically create a command button.
  5. Set the AutoRepeat property of the command button to Yes. Note that the command button's OnClick property is set to the name of the macro.
  6. View the Customers form in Form view to browse the form and click the command button. Note that each time you click the command button, the record selector moves to the next record. When you click and hold down the command button, you would expect Microsoft Access to scroll rapidly to the last record in the table, but this does not happen. Instead, the record selector moves to the next record only, regardless of the command button's AutoRepeat property setting.

    However, if you add a macro that uses a different macro action, such as Beep, to the form, the AutoRepeat action works as expected. This is because Beep does not change the focus.

REFERENCES

For more information about the AutoRepeat property, click Microsoft Access Help on the Help menu, type autorepeat property in the Office Assistant or the Answer Wizard, and then click Search to view the topic.


For more information about command button control properties, click Microsoft Access Help on the Help menu, type command button control properties in the Office Assistant or the Answer Wizard, and then click Search to view the topics returned.

Modification Type:MajorLast Reviewed:6/28/2004
Keywords:kbprb KB209669