Count of Records in a Subform

  • Thread starter Thread starter DEI
  • Start date Start date
D

DEI

I have a form with a sub form. I would like to create a
control on the main form that counts the records in the
subform. Is there a way to use =Count function to do so?

Thanks in advance.
 
I have a form with a sub form. I would like to create a
control on the main form that counts the records in the
subform. Is there a way to use =Count function to do so?

Thanks in advance.
Here is one way. Create the following function and use it in the
control source of the textbox to display a record count.

Private Function fSubFormRecCount() As Long
Dim frm As Form

Set frm = Me.SubformControlName.Form
frm.RecordsetClone.MoveLast
fSubFormRecCount = frm.RecordsetClone.RecordCount
Set frm = Nothing

End Function

Replace SubformControlName with yours and then put

=fSubFormRecCount()

in the Control Source of the textbox

- Jim
 
Back
Top