Subtotal From Subform To Mainform

C

Charlene

I have an Invoice/Invoice Details form/subform. In the page footer of the
Invoice Details subform I have a textbox with the control source set to
=Sum([SalesAmount]). I then pull this value into the main form with a textbox
whose control source is =[SFrmInvoiceDetails]![TotalSalesAmount]. This works
fine when there are one or more line items in Invoice Details but on a new
invoice before any invoice details are entered, the textbox on the main form
shows #Error. I would like it to show $0.00. I have tried the NZ function in
different places without success; I keep getting #Error no matter what I try
when there are no records in the subform. What is the correct way to set this up
so that the main form shows $0.00 when there are no records in the subform and
then the total of the line items after one or more line items are entered?

Thanks for all help!

Charlene
 
K

Ken Snell

Nz function won't get a chance to do anything when the subform has
nothing to sum. Actuall subform is totally suppressed
when there are no data for it to process.

This must be dealt with in the main form by making a label
control with a caption of "0" visible or not:

Me.lblZero1.Visible = Not Me.subform.Form.RecordsetClone.RecordCount
 

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