Counting records returned on subform

  • Thread starter Thread starter Silvester
  • Start date Start date
S

Silvester

I do a search on my A2000 mdb and return the results on a subform.

Is there any way to count the number of records returned by the subform when
it loads and display it on a messagebox saying "x matching records found"
just after the subform displays ?

Thanks for any help.
 
Use the following in code in your subform:
Dim Rst As DAO.Recordset
Dim MatchingRecords As Long
Set Rst = Me.RecordsetClone
If Rst.RecordCount <> 0 Then
Rst.MoveLast
End If
MatchingRecords = Rst.RecordCount

Use the following in code in your main form:
Dim Rst As DAO.Recordset
Dim MatchingRecords As Long
Set Rst = Me!NameOfSubformControl.Form.RecordsetClone
If Rst.RecordCount <> 0 Then
Rst.MoveLast
End If
MatchingRecords = Rst.RecordCount
 
Thank you. That worked perfectly. I just added an
Exithere:
set rst = nothing
to the error handling.
 
Back
Top