referring to Subform Total in main form

  • Thread starter Thread starter Jim Franklin
  • Start date Start date
J

Jim Franklin

Hi,

This is probably very simple but has bugged me on more than one occasion. I
have a main form / continuous subform setup, where the subform contains a
control ctlFieldX bound to FieldX and a control ctlTotal in the form footer
to display the sum of FieldX. This controlsource =sum([FieldX])

On my main form, I might have a control which references the total in the
subform, with a controlsource =nz(Subform.Form!txtTotal,0)

The problem occurs when the subform does not have any related records to
display. If the AllowAdditions property of the sunform is set to True, the
main form total control correctly displays 0. However, if the AllowAdditions
property is set False, the main form total control displays #Error

Can anyone tell me if there is a simple way around this?

Thank you as always,

Jim
 
Try checking whether Subform.Form.RecordsetClone.RecordCount is 0:

=IIf(Subform.Form.RecordsetClone.RecordCount, Nz(Subform.Form!txtTotal,0),
0)
 
Back
Top