DSum

G

Guest

Hello.
I have a subform located on the footer of a Form.
I need to Sum everything in the subform "HrCost" field.

These are the form names:
Main form name: frm_ProjectDetails
Subform name: frm_ProjectDetailsSubform


I created a text box with the following Control Source.
=DSum("[HrCost]","tbl_MainDateServiceInfoSub","[Category]=[frm_ProjectDetails].[Form]![ProjectOrCategoryName]")


I get the #error on that field when I am in form view.
Is there an easier way of doing this or can you help me fix the code.

Thanks.
Your help is greatly appreciated.

Iram/mcp
 
D

Douglas J. Steele

It's not clear to me whether ProjectOrCategoryName is on the main form (i.e.
frm_ProjectDetails) or on the subform (frm_ProjectDetailsSubform).

If ProjectOrCategoryName is on frm_ProjectDetail, try

=DSum("[HrCost]","tbl_MainDateServiceInfoSub","[Category]=[Forms]![frm_ProjectDetails]![ProjectOrCategoryName]")

If it's on frm_ProjectDetailsSubform, try:

=DSum("[HrCost]","tbl_MainDateServiceInfoSub","[Category]=[Forms]![frm_ProjectDetails]![frm_ProjectDetailsSubform].Form![ProjectOrCategoryName]")

Actually, you'll need to check the name of the subform control on
frm_ProjectDetails: depending on how you added frm_ProjectDetailsSubform as
a subform on frm_ProjectDetails, the name of the subform control may
something other than frm_ProjectDetailsSubform. If it is different, you need
to use the name of the subform control.
 
G

Guest

Hello Douglas.
My friend walked by right after I sent the post and we got it resolved.

Thanks!
You are the man anyways!

Iram/mcp

Douglas J. Steele said:
It's not clear to me whether ProjectOrCategoryName is on the main form (i.e.
frm_ProjectDetails) or on the subform (frm_ProjectDetailsSubform).

If ProjectOrCategoryName is on frm_ProjectDetail, try

=DSum("[HrCost]","tbl_MainDateServiceInfoSub","[Category]=[Forms]![frm_ProjectDetails]![ProjectOrCategoryName]")

If it's on frm_ProjectDetailsSubform, try:

=DSum("[HrCost]","tbl_MainDateServiceInfoSub","[Category]=[Forms]![frm_ProjectDetails]![frm_ProjectDetailsSubform].Form![ProjectOrCategoryName]")

Actually, you'll need to check the name of the subform control on
frm_ProjectDetails: depending on how you added frm_ProjectDetailsSubform as
a subform on frm_ProjectDetails, the name of the subform control may
something other than frm_ProjectDetailsSubform. If it is different, you need
to use the name of the subform control.


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Iram said:
Hello.
I have a subform located on the footer of a Form.
I need to Sum everything in the subform "HrCost" field.

These are the form names:
Main form name: frm_ProjectDetails
Subform name: frm_ProjectDetailsSubform


I created a text box with the following Control Source.
=DSum("[HrCost]","tbl_MainDateServiceInfoSub","[Category]=[frm_ProjectDetails].[Form]![ProjectOrCategoryName]")


I get the #error on that field when I am in form view.
Is there an easier way of doing this or can you help me fix the code.

Thanks.
Your help is greatly appreciated.

Iram/mcp
 

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