Count of records in subform

latex88

Registered User.
Local time
Today, 06:50
Joined
Jul 10, 2003
Messages
198
I have a form that has a subform in it, which is another table in it. I want to add the number of fields that are in the subform. What is the best way to do so?

I would like to write a VB script so that a field in the master field = the count of the records in that subform. Any help is greatly appreciated. Thanks.
 
Me.SubFormControl.Form.RecordsetClone.Movelast
Me.SubFormControl.Form.RecordsetClone.MoveFirst
Me.MainFormField = Me.SubFormControl.Form.RecordsetClone.RecordCount

Using your form names of course.
 
Thanks RuralGuy. I'm a beginner when it comes to VB. Would you mind elaborating each line. Also, where do I insert the name of the main and subform? Thanks.
 
And put the code in the Current event of the main form.

The Bold Red names need to be yours:
Code:
Me.[b][COLOR=Red]SubFormControl[/COLOR][/b].Form.RecordsetClone.Movelast
Me.[b][COLOR=Red]SubFormControl[/COLOR][/b].Form.RecordsetClone.MoveFirst
Me.[b][COLOR=Red]MainFormControl[/COLOR][/b] = Me.[b][COLOR=Red]SubFormControl[/COLOR][/b].Form.RecordsetClone.RecordCount
 
=Count(*) in the control source of a textbox in the subform footer will do it, no vba is needed
 
But Rich, how do I go about calling that number in a field in my main form?
 
Thanks a lot Pat. That was much simpler.
 

Users who are viewing this thread

Back
Top Bottom