Adding values in subforms

ABreeze

Registered User.
Local time
Today, 16:34
Joined
Mar 15, 2002
Messages
22
I'm having a bit of a problem with a subform. My main form tracks applications and the subform tracks projects within that application. I have the subform opening in datasheet view and I want to total the columns for each application. I have text boxes placed in the subform footer to hold the totals and a command button next to each one to calculate but none of the code I use seems to fill the boxes properly.

My subform field is projectCost and the footer field is totalProjectCosts.
 
I would view the form as a continuous view, not datasheet.
 
It is already continuous. Sorry about that. I still don't know how to generate totals
 
What code have you got? Is it in the text box in the footer?
 
I had planned to place code in the on click property of a command button placed next to the total text box but I don't really have any code. That's my problem. I've tried several different variations but none would total. I'd just get the amount from one project. I guess it would be better to place the code on the text box, though, wouldn't it. That way the total box will add each new entry. I'm unfamiliar with using subforms this way and I'm unsure how Access handles these forms in relation to the main form. What property of the text box can I place the code on. I assume it would be fairly simple code ie. totalProjectCosts = totalProjectCosts + projectCost.

Thank you so much for your help.
 
The code goes into the ControlSource property of your text box (the same as typing directly into the text box).

=[totalProjectCost]+[projectCost]
 
I tried that but I get an #error now in my text box.
 
Make sure your text box doesn't have the same name as anything in the sum like totalProjectCosts - preceed it with txt (txtTotalProjectCosts) or something, otherwise it causes a circular reference and you'll get #Error.
 
Now its just adding the value of the first project to itself! It seems that no matter what I do , I only get code to work on the first project cost. I need to add each project for a grand total. What am I doing wrong???

I really appreciate your patience...
 
I'm now a bit confused. Is is possible for you to attach db?
 
My database is much to large to send but I'll send a screenshot of the form. From that you should be able to see what I am trying to do. Thanks again.
 
Hope I'm understand this right:

If you want a total of each column then the formula you want is:

=Sum([AmountRequested]) ... or whatever the name of your fields are.

HTH - If I'm wrong, please let me know.
 
That's it ! That's all I wanted. I knew it had to be something simple but I couldn't get my formula correct (or in the correct spot). Thank you so much. You're a lifesaver...
 

Users who are viewing this thread

Back
Top Bottom