Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to totalize values from a SUBFORM TextBoxes into a FORM TextBox

Status
Not open for further replies.

fuldingo

Programmer
Jul 1, 2002
12
PK
I have a form called "invoice" and a subform called "invoice_detail". In the subform i have a TextBox called "subtotal" that
store the amount for each item of the invoice (is the result of multiply "quantity" by "price_unit". Now, what i want is to
show the total amount of the invoice in other TextBox called "total" but in the Form "invoice". I want to update this field
as i am adding fields into "invoie_detail" subform.

Thank you.

MM
 
I am assuming that the subtotal field is added to a table for a particular invoiceNo? If so, one way to do this is to run a query that sums the subtotals for the invoice number in question. Assign the sum to Forms!Form!Invoices.Total You can run the query in the On Current event of the subform or the After Update event of the subtotal text box, depending on when you want it to update the total on the main form. If you include the query in the On Current event, the total will update when you save a record on the subform and go to the next line. If you include the query in the After Update of the text box, the total will update as you enter new subtotals. I'm sure that there are other ways to do this, but this is one. dz
dzaccess@yahoo.com
 
place a textbox named invtotal in the footer of the subform.
set its controlsource to =sum(subtotal)
This should give you a total of the subtotals. You can hide this if you wish
then in the main form, the textbox you want to display the total, set its control source to the name of the textbox on the subform

=[invoice_detail].Form![invtotal]

it should now perform as you requested
 
Thank you gol4, but i still have a problem. In the Form i set the control source of the text box TOTAL like this:
=[Forms]![invoice_detail]![invtotal], but i´m getting #Name?
as response. I have the sum on invtotal already but my now my problem is bring this value from the subform to the form.

Thank you.

MM
 
hi there
using the invtotal it may need
= forms!frminvoice!invoice_detail.form!invtotal

slightly different sytax but should be about there
 
Joannes suggestion should work but the syntax I posted should work as well

did you try as I posted
=[invoice_detail].form![invtotal]
as the control source for the total textbox on the main form

you said you used
=[Forms]![invoice_detail]![invtotal]
that will not work
 
Thank you very much. Finally i´ve got what i want. Thanks JoanneM and Gol4..

Fuldingo.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top