Count the number of subform records associated with parent record

Count the number of subform records associated with parent record

Hello!

I have a main form which contains all the details of a particular Issue, and then a subform where we can enter some information about each client who is affected by that Issue.

What I want to do is have a field in the main form contain a count of the number of clients who have been affected, and automatically update when a new client's information is entered in the subform. Essentially, just a count of the records in the subform that are associated with that parent record.

I've tried variations of a 'for each record in subform', .size() functions and more, but can't quite seem to hit on the right function or code to let me do this - I either get 0, or the total number of records in the subform as a whole, not just those related to the parent record.

Any hints?

Thanks!