This example illustrates use of the RowCount property to determine if any rows resulted from the query and how many rows have been processed after each MoveNext method is executed and how many rows are in the result set once all rows are processed.
Option Explicit
Dim ps As rdoPreparedStatement
Dim rs As rdoResultset
Dim cn As rdoConnection
Private Sub Form_Load()
Dim SQL As String
Set cn = MSRDC1.Connection
SQL = "{call ChooseAuthor (?)}"
Set ps = cn.CreatePreparedStatement("GetAuthor", SQL)
End Sub
Private Sub Search_Click()
ps(0) = NameWanted.Text
Set MSRDC1.Resultset = ps.OpenResultset( _
rdOpenKeyset, rdConcurReadOnly)
With MSRDC1.Resultset
If .RowCount = 0 Then
MsgBox "No titles by that author were found."
NameWanted.SetFocus
Else
Do Until .EOF
.MoveNext
TitlesFound = .RowCount ' How many so far
Loop
TitlesFound = .RowCount ' Total rows found
End If
.MoveFirst
End With
End Sub