Count of Records in Subform

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello:

I have a form called Work Orders and on it is a subform called Work Order
Details. On my main form there is an field named ItemCount. I need to know
how to programtically put a count of all of the records on my Work Order
Detail Subform into this field.

Thanks
 
In general, you should not store the count on the parent form.

Instead, place a text box in the Form Footer part of the subform, and give
it these properties:
Control Source =Count("*")
Format General Number
Name txtKt

You can hide the section if you want, and display the total in a text box on
the main form with:
=[Sub1].[Form]![txtKt]
where "Sub1" is the name of your subform control.

For more info on how to refer to a control in the subform, see:
http://allenbrowne.com/casu-04.html
and for help on calculated controls, see:
http://allenbrowne.com/casu-14.html

For an example of bringing a subform total back onto the main form, open
Northwind, and look at the Orders form.
 
Thanks

Allen Browne said:
In general, you should not store the count on the parent form.

Instead, place a text box in the Form Footer part of the subform, and give
it these properties:
Control Source =Count("*")
Format General Number
Name txtKt

You can hide the section if you want, and display the total in a text box on
the main form with:
=[Sub1].[Form]![txtKt]
where "Sub1" is the name of your subform control.

For more info on how to refer to a control in the subform, see:
http://allenbrowne.com/casu-04.html
and for help on calculated controls, see:
http://allenbrowne.com/casu-14.html

For an example of bringing a subform total back onto the main form, open
Northwind, and look at the Orders form.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Brennan said:
I have a form called Work Orders and on it is a subform called Work Order
Details. On my main form there is an field named ItemCount. I need to
know
how to programtically put a count of all of the records on my Work Order
Detail Subform into this field.
 
Back
Top