Microsoft KB Archive/90806

= ACC: GoToControl to Control with Focus in AfterUpdate Ignored =

Article ID: 90806

Article Last Modified on 1/18/2007

-

APPLIES TO


 * Microsoft Access 1.0 Standard Edition
 * Microsoft Access 1.1 Standard Edition
 * Microsoft Access 2.0 Standard Edition
 * Microsoft Access 95 Standard Edition
 * Microsoft Access 97 Standard Edition

-



This article was previously published under Q90806



Moderate: Requires basic macro, coding, and interoperability skills.



SYMPTOMS
When a control has the focus and the GoToControl action is carried out with the same control name that has the focus, the focus will move to the next control in the tab order. The focus will not stay on the control that currently has the focus, as you would expect.



RESOLUTION
To prevent the focus from leaving the field, you can use an OnExit macro that performs the CancelEvent action. Or, if you want to prevent the field from being saved (and also prevent the focus from leaving the control), you can use a validation rule or a BeforeUpdate macro.



STATUS
This behavior is by design.



Steps to Reproduce Behavior
  In the sample database Northwind.mdb (or NWIND.MDB in versions 1.x and 2.0), create the following macro named Test1:

  Macro Name   Condition         Action --  Test1        ([City]=&quot;aaaa&quot;)   GoToControl

Test1 Actions -  GoToControl Control Name: [City]  Open the Customers form in Design view. Set the City control's AfterUpdate property to the Test1 macro. View the Customers form in Form View. Type aaaa in the City field and press TAB. Note that the focus moves to the next field in the tab order. However, if you had moved to another control before pressing TAB, the focus would not have changed.</ol>

<div class="references_section">