referring to Subform Total in main form


Jim Franklin


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,


Douglas J. Steele

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

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question