Subform form calculation

  • Thread starter Thread starter Nate via AccessMonster.com
  • Start date Start date
N

Nate via AccessMonster.com

Hello
Does anyone know how to add the records in one column in a subform and
display them onto the main form?

I have a subtotal column in my subform that adds the quantity and the
amount of the part being purchased. I would like to add all of the part
subtotals and display them in a textbox on my main form for a grand total

Please be specific as I am a beginner.

Thanks
Nathan
 
Nathan,

In the text box on your main form set the RecordSource property to the
following

=DSum("ColName","Table","LinkField = '" & LinkField & "'")

where "ColName" is the column name in your sub form underlying table/query,
"Table" is the table/query that your subform is based on & "LinkField" is the
Key field that links your main form to the records of your sub form.

Dennis.
 
Hello Dennis

I tried your suggestion but I receive an error when I placed in my code:
Compile error. Expected: line number or label or statement or end of
statement.

When I click ok the = sign is highlighted.

My code looks like this:
=DSum("TotalPrice","Parts","PartId = '" & PartId & "'")

PartId is the name of the field in my subform table that I linked to.
Should I use the field name in my subform table or the main table that I
linked to? The name I used for my main table is PoId. Basically I linked
PartId to PoId.

Any suggestions??

Thanks
Nathan
 
If PartID is text then try .... "PartId = '" & Me.PartID & "'")
or if PartID is numeric then try ..... "PartID = " & Me.PartID)
 
Dennis
Thanks for the help.

I tried your suggestion and placed my code in Control source. When I tried
it, I received a #Name? error. Im not sure what this means.

This is the code I used.
=DSum("TotalPrice","Parts","PartID = " & Me.PartID)

If I put this code in control source will I not be able to store the total
in the table?? I thought control source had to be the field in the table
you are trying to store the calculation in. I would like to store the
total in a table. Sorry for not mentioning this before.

I have also tried =Sum([TotalPrice]) but it won't add everything in the
column. All I get is a 50 in the textbox. I'm not sure why it is
displaying a 50. If I change the amounts in (TotalPrice) I still get 50.

Thanks again
Nathan
 
Back
Top