Subform Total to Main Form Textbox

jon2371

Registered User.
Local time
Today, 07:13
Joined
Aug 2, 2012
Messages
20
Hi Experts,

I created a Primary Form & a Sub Form (datasheet), the subform have a QTY Field and i need to sum this QTY Field and make it appear on a textbox in Primary Form.


Please help.

Thanks,
Jon
 
Please create a text box a subform footer. In control source of this text box, write Something like below

=Sum([OrderPrice])

OrderPrice is the name of field in which you are interested to make a total.

Then on the main form, again create a text box and write in the control source something like this:

=[sbfOrderDetails]![TotalOrderPrice]

here sbfOrderDetails is name of your subform and TotalOrderPrice is the name of the text box created on subform for total above.

Hoe it helps.

best regards.
 
Hi Sir,

I created a TextBox (txtTotalQty2) in SubForm footer and type a
formula in Control Source Property.
=Sum([txtqty2])

And also created a TextBox (txtRejectTotalQty) in Primary Form
and type a formula in Control Source Property
=[DetailRejectMachSF].[Form]![txtTotalQty2]

But i encounter error in txtRejectTotalQty..the content of textbox is "#Error"

Thanks,
Jon

Thanks,
Jon
 
=[DetailRejectMachSF].[Form]![txtTotalQty2]

Please try after removing .[Form] in above line.

regards.
 
Last edited:
i tried to remove the Form.

the error is #Name?

Thanks..
Jon
 
=[DetailRejectMachSF]![txtTotalQty2]

It should be like above, I checked it and I think you are keeping . and removing !

am I correct?

I could not find anything wrong other than this.
 
Before you create the textbox in the main form, is the sum in the subform's Footer section actually working?
 
i tried to remove the =sum in =sum(txtqty2) in subform footer textbox and it works... but if i used the SUM there the error "#ERROR" in mainform textbox..

:banghead:
 
That was not my question. Look at the subform and see if the Sum is working there. The subform, not the main form.
 
No Sir, the Sum is not working in subform footer
 
Right, what are the names of the form and subform I should be looking at?
 
Hi Sir,

Primary Form Name : HeadRejectMachF
SubForm Name : DetailRejectMachSF

i have created a textbox (txtTotalQty2) in footer of DetailRejectMachSF, and need to link to textbox (txtTotalReject) in MainForm.

Thanks,
Jon
 
You sum the field, not the textbox. The field name is qty so you need to put =Sum(qty)
 
I am using Access2007 in XP (please don't judge). So, I have looked everywhere on the Internet. I have even been reading Access 2007 All-in-one for dummies. I think I have done everything right. I have a mainform (frmOrders) linked to a subform(sfrmOrderDetails).

I have an unbound text box in the subform footer (fldItemSum) with control source =Sum([order_details_tbl]![o_unit_price]*[order_details_tbl]![qty]). The value is definitely coming from the table fields, not the subform text fields.

Now, on my mainform, I have a field called order_sub with control source =[sfrmOrderDetails].[Form]![fldItemSum].

Here's the problem:

1. When I open the subform by itself (continuous format), fldItemSum calculation works fine.

2. When I close the subform, then open the mainform containing the subform, both fldItemSum and order_sum both show #Error.

3. I close the mainform, then open the subform again, and I get #Error in fldItemSum.

4. I close the subform and reopen it and the fldItemSum calculation works again.

I am banging my head against the wall. I think there has to be something either wrong with the mainform or the table. I'v tried renaming fields and text boxes. I don't know where to go from here. Here is the db.
 

Attachments

Mahenkj2, thanks for the reply. This doesn't quite solve my problem, though. I have read this article and my form is set up accordingly. I only have the subform in continuous view so that I can make sure that the calculated field in the subform footer works. My long-term plan is to use datasheet view for the subform. In fact, if I switch to datasheet view, the mainform field (order_sub) still shows #Error.
 

Users who are viewing this thread

Back
Top Bottom