Microsoft KB Archive/275062

= ACC2002: ADO EndOfRecordset Event Is Not Triggered with Form Recordsets =

Article ID: 275062

Article Last Modified on 11/5/2003

-

APPLIES TO


 * Microsoft Access 2002 Standard Edition

-



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.



Steps to Reproduce the Behavior
 Create a new Access project (ADP) that is based on Pubs sample database. On the Insert menu, click Class Module to create a new class module.  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 &quot;End Of Recordset&quot; End Sub  Save the module as Class1, and then close it. In the Database window, click the Authors table, and then click AutoForm on the Insert menu. Open the new form in Design view, and then click Code on the View menu.</li>  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 </li> Open the form in Form View.</li> Press CTRL+G to open the Immediate window.</li>  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. </li>  Press CTRL+G again, and then type the following code in the Immediate window, and press ENTER: ?Forms(0).Recordset.MoveNext </li></ol>

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.

Additional query words: pra prb isn doesn t run happen occur

Keywords: kbnofix kbprb KB275062

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.