Main Control References SubForm Control

M

Michael

Hi Folks - I have a Main Form calculated control that references a hidden
subform calculated control that sums a field. Typically, there is no problem
except when the subform does not display any records. If this happens, the
main form calculated control displays #error. I'd prefer is display 0.
What's the best way to handle this? Thanks.

Michael
 
D

Dirk Goldgar

Michael said:
Hi Folks - I have a Main Form calculated control that references a hidden
subform calculated control that sums a field. Typically, there is no
problem except when the subform does not display any records. If this
happens, the main form calculated control displays #error. I'd prefer is
display 0. What's the best way to handle this?

I use Keri Hardwick's nnz() function, posted here:

http://www.mvps.org/access/forms/frm0022.htm
Forms: #Error when the Subform has no records
 
M

Marshall Barton

Michael said:
Hi Folks - I have a Main Form calculated control that references a hidden
subform calculated control that sums a field. Typically, there is no problem
except when the subform does not display any records. If this happens, the
main form calculated control displays #error. I'd prefer is display 0.
What's the best way to handle this?


You can do it all in your text box expression using this
kind of thing:

=IIf(subform.Form.Recordset.RecordCount=0, 0,
subform.Form.subtotal)
 

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

Top