ACC: No AutoRepeat with GoToRecord/Next and DoMenuItem (95645)



The information in this article applies to:

  • Microsoft Access 1.0
  • Microsoft Access 1.1
  • Microsoft Access 2.0
  • Microsoft Access for Windows 95 7.0
  • Microsoft Access 97

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

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. Here are two points that need clarification before the cause can be explained:
  • OnClick property: The macro under the OnClick property of a command button normally will not run until you push 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 pushed and the mouse pointer is in the command button's region.

    NOTE: The OnClick property is called the OnPush property in version 1.x.
  • Focus: Several macro actions change the focus. For example, GoToControl, GoToRecord, OpenForm, OpenTable, and ApplyFilter change the focus.

    Therefore, if a command button's OnClick property macro changes the focus, for example, to the next record, then the command button has lost the focus; that is, when you click the command button, the click does not apply to that command button anymore because the focus has changed. It's as if you had moved the mouse pointer off the command button while pressing the mouse button, as if the command button moved out from under the mouse pointer right before you pressed the mouse button.

STATUS

This behavior is by design.

MORE INFORMATION

Steps to Reproduce Behavior


  1. Start Microsoft Access.
  2. Open the sample database Northwind.mdb (or NWIND.MDB in versions 1.x and 2.0).
  3. Create a new macro as follows and save it as AutoRepeatTest:

           Macro Name      Action
           --------------------------
           AutoRepeatTest  GotoRecord
    
           AutoRepeatTest Actions
           --------------------------
           GoToRecord
              Object Type:  Form
              Object Name:  Customers
              Record:       Next
    						
  4. Open the Customers form in Design view.
  5. Drag the macro you have just created onto the form to create a command button.
  6. 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.
  7. 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.

Modification Type:MajorLast Reviewed:5/28/2003
Keywords:kbprb KB95645