Tuesday, December 11, 2007

How to use the EOF and BOF of database

How to use the EOF and BOF of database

To use the EOF and BOF of database

EOF = return a value that indicates whether the current record position is before the first record in a Recordset object.

BOF = return a value that indicates whether the current record position is after the last record in a Recordset object.

Step 1:

Double click on the ADODC Control:

Step 2:

Choose the Move Complete event:

Step 3:

In this example, write down the programming codes:

Private Sub Adodc1_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)

If Adodc1.Recordset.BOF Then

Adodc1.Recordset.MoveFirst

MsgBox "This is a First Record", vbQuestion, "Warning"

End If

If Adodc1.Recordset.EOF Then

Adodc1.Recordset.MoveLast

MsgBox "This is a Last Record", vbQuestion, "Warning"

End If

End Sub

In this example, a message box will alert user if it has reached the last or first record.


No comments: