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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculating a sum whem some of the data is negative

Status
Not open for further replies.

billheath

Technical User
Mar 17, 2000
299
US
I have a field in a subform labeled [Loss/Gain]. I need to put the sum on the main form. The numbers can be either positive or negative. I am using "Sum([Loss/Gain]) in the field. I know from reading other sources that summing on a calculated field may be a problem as well as negative numbers. Is there a work around I can use. Thanks very much.
Bill
 
I dont think that the negative numbers should be a problem.

you dont need to know the lable name or caption but the text box name

and use this on the main form =sum(forms!formname!subfromControlName!Textboxname)
 
Thanks, PWISE; That is exactly what I did. When I try to run it, I get "ERROR". I have tried putting it on the main form, in the footer etc. All come back with "ERROR". [Loss/Gain] is a calculated field in the underlying query. I wonder if that has something to do with it.
 
The subform label doesn't have any value. Also, you can't sum a control. What is important is the field in the subform. I would add a control in the subform header or footer to calculate the total of the field. Set it's properties:
Name:txtMySum
Control Source: =Sum([Your Field Name Here])

Then in the main form, add a text box:
Control Source:=[Your Subform Control Name].[Form].[txtMySum]



Duane
Hook'D on Access
MS Access MVP
 
thank you. That worked. Sorry, it took so long to try it. But, It worked!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top