ACC2002: ADO EndOfRecordset Event Is Not Triggered with Form Recordsets (275062)



The information in this article applies to:

  • Microsoft Access 2002

This article was previously published under Q275062
Advanced: Requires expert coding, interoperability, and multiuser skills.

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

SYMPTOMS

The ADO EndOfRecordset event is not triggered with form recordsets.

STATUS

This behavior is by design.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Create a new Access project (ADP) that is based on Pubs sample database.
  2. On the Insert menu, click Class Module to create a new class module.
  3. Type or paste the following code in the class module:
    Option Compare Database
    Option Explicit
    
    Private WithEvents r As ADODB.Recordset
    
    Public Property Get Recordset() As ADODB.Recordset
         Set Recordset = r
    End Property
    
    Public Property Set Recordset(rsIn As ADODB.Recordset)
         Set r = rsIn
    End Property
    
    Private Sub r_EndOfRecordset(fMoreData As Boolean, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
       MsgBox "End Of Recordset"
    End Sub
    					
  4. Save the module as Class1, and then close it.
  5. In the Database window, click the Authors table, and then click AutoForm on the Insert menu.
  6. Open the new form in Design view, and then click Code on the View menu.
  7. Add the following code:
    Option Compare Database
    Option Explicit
    
    Private c As New Class1
    
    Private Sub Form_Open(Cancel As Integer)
         Set c.Recordset = Me.Recordset
    End Sub
    					
  8. Open the form in Form View.
  9. Press CTRL+G to open the Immediate window.
  10. Type the following code in the Immediate window, and then press ENTER:
    ?Forms(0).Recordset.MoveLast
    						
    Note that the form correctly moves to the last record as expected.
  11. Press CTRL+G again, and then type the following code in the Immediate window, and press ENTER:
    ?Forms(0).Recordset.MoveNext
    					
Note that the EndOfRecordset event is not triggered. If you open an ADO recordset programmatically and perform the same steps, the EndOfRecordset event is triggered.

Modification Type:MajorLast Reviewed:11/5/2003
Keywords:kbnofix kbprb KB275062