ACC2000: OnEnter Event Occurs Each Time That You Move to a Different Record (225061)



The information in this article applies to:

  • Microsoft Access 2000

This article was previously published under Q225061
This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).

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

SYMPTOMS

The OnEnter event for a control occurs each time that you move to a different record on a form.

CAUSE

The control that has the OnEnter event has the focus as you move through the form.

STATUS

This behavior is by design.

MORE INFORMATION

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.

Steps to Reproduce the Behavior

  1. Open the sample database Northwind.mdb or the sample Access project NorthwindCS.adp.
  2. In the Database window, click Tables under Objects, click the Orders table, and then on the Insert menu, click AutoForm.
  3. On the View menu, click Design View.
  4. Set the OnEnter property of the OrderDate text box to the following event procedure:
    Option Compare Database
    Option Explicit
    
    Private Sub OrderDate_Enter()
        Me!OrderDate = Date
    End Sub
    					
  5. On the Debug menu, click Compile <DbName>.
  6. Close the Visual Basic Editor, and on the View menu in Access, click Form View.
  7. Move through the first 5 or 6 records. Note that the dates appear as expected in the Order Date box.
  8. Return to the first record, and then click in the Order Date box. Note that the first record and every other record that you move to immediately changes to today's date as the OnEnter event occurs as you move through the records.

Modification Type:MajorLast Reviewed:6/24/2004
Keywords:kbprb KB225061