Calculated Fields

M

MsDYJ

I have a main form with several subforms connected to it. 1 of the subforms
shows the material cost and the qty. used. Another subform shows the price of
a resource and the hours worked. I want the actual cost field in the main
form to display the total of the sum of all the material costs and the sum of
all the resource cost.

I used an unbound textbox and in the control source used the formula:
=Sum(MaterialCost*QTY) + Sum(ResourceCost*HrsWorked)and some other formulas
but keep getting an error. Does any one have any suggestions?
Thanks!
 
A

Al Campagna

MsDYJ,
It would be easier if you created the calculation on each subform,
and just have the Main form refer to (and add) those values.
Given a calculated text control named MatCosts on the MaterialCost sub,
=Sum(MaterialCost*QTY)
and another calcuulated text control named ResCosts on the Resource sub...
=Sum(ResourceCost*HrsWorked)
then a text control on the Main form with this ControlSource of...
(all on one line)
= Forms!frmMainFormName!frmMaterialSub.Form!MatCosts +
Forms!frmMainFormName!frmResourceSub.Form!ResCosts
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
M

MsDYJ

Al,

I'm mo longer getting the erro message, now i'm getting #Name?

Any more suggestions?

Thanks a mil!
MsDYJ
 
A

Al Campagna

MsDYJ,
Which calculations give you an #Name error?
The Material calc? The Resource calc? Or the Main form calc?

Whenever you have problems with code, Copy & Paste exactly what
you put in the Main form calculation (that brings the Material and Resource
values together). We need to see the failing code or expression.

If it's the Main form calc, then one of the names in the calculation
string
can't be located by Access.
This Control Source calculation... (enter it all on one line)

= Forms!frmMainFormName!frmMaterialSub.Form!MatCosts +
Forms!frmMainFormName!frmResourceSub.Form!ResCosts

should work if each of those named objects really exist.

**We need to know the following...
The exact Main form name.
The Materials Sub name.
The Resource Sub name.
The name of the field in Materials Sub that has the correct calculation.
The name of the field in Resource Sub that has the correct calculation.
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 

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