Getting #Error in a subform footer

I have a main form, single form view.  And then in that form, a sub-form whish is a datasheet view.  In the footer section of the subform I am trying to sub the value of a field named txtGross (Gross is the control source).

What I have for the field's control source in the footer is =Sum([txtGross])  

But I'm getting #Error.

????
SteveL13Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gustav BrockCIOCommented:
A form in datasheetview has no header or footer, so ...?
0
SteveL13Author Commented:
In design view it does.  I know it can't be visible but it is there.  And I thought that even if it won't be visible I could put calculated fields in it. ????
0
Gustav BrockCIOCommented:
Never thought of that. But for what purpose? As you probably intend to use the sum elsewhere.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

mbizupCommented:
Are you sure the subform in question is not in Continuous Forms view?  I haven't tested it, but I wouldn't even expect to see the #Error in Datasheet View.  

Anyhow, this is the root of your problem:  "field named txtGross (Gross is the control source)"

The FIELD is actually named "Gross" if that is the control source.  txtGross is the name of the Textbox Control, not the field.  All of the aggregate functions (Sum, Avg, Max, etc) require the FIELD as the parameter, and using the control name will cause an error.  

So try this:

=Sum([Gross]) 

Open in new window

0
SteveL13Author Commented:
mbizup:  I changed it to =Sum([Gross])  and still get #Error.

Gustav:  I have it in the footer of the sub-form and am then pulling it over to the main form footer with: =[Forms]![frmAssemblySheetHeader].[Form]![subfrmAssemblySheetDetail].[Form].[txtSumGross].  But I get #Error in the main form footer also because of the #Error in the sub-form footer.
0
mbizupCommented:
Does Sum([gross]) Produce an error on it’s own in the sub form, or just in the control on your main form?

Also, is Gross a calculated field?
0
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
hi Steve,

> "... sub-form whish is a datasheet view.  In the footer section of the subform ..."

You will need to make a continuous (multiple items) form to be able to use the Header and Footer sections (or a single form but that only shows one record at a time) since Datasheet forms ignore calculated controls that are there.

have an awesome day,
crystal
0
SteveL13Author Commented:
Crystal, I was able to make this work in datasheet view using the form's footer.  I realize it doesn't display but I was able to copy the value in the footer over to the main form's field.

Mbizup, yes, Gross WAS a calculated field.  I changed it by making it an expression in the record source of the datasheet form (the record source)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
Steve, since you put the calculation in the RecordSource, does it work now?  If now, would you share your formula?
0
SteveL13Author Commented:
Gross: IIf((Nz([MST],0)-Nz([Forms]![frmAssemblySheetHeader].[txtMoistureMax],0))*Nz([CleanCWT],0)*Nz([Forms]![frmAssemblySheetHeader].[txtDisSchd1],0)>=0,(Nz([MST],0)-Nz([Forms]![frmAssemblySheetHeader].[txtMoistureMax],0))*Nz([CleanCWT],0)*Nz([Forms]![frmAssemblySheetHeader].[txtDisSchd1],0),0)

(Is an Expression in query designer).
0
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
hi Steve,

assuming these are bound controls, instead of referring to controls in the expression, it would be better to make a query with the data for the calculation.  Then add that query to the RecordSource for the  subform -- using Left or Right join, whichever shows all records from the table for the subform. When the mainform record is updated (form AfterUpdate event), the subform will need to be requeried.

have an awesome day,
crystal
0
SteveL13Author Commented:
Thank you for the tip.  I appreciate it.
0
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
you're welcome, Steve.  In that query you will also need to put the key field(s) to link on.  Also, that is where I would put NZ so it doesn't have to be tested again.

have an awesome day,
crystal
0
mbizupCommented:
Aggregate functions will not work over expressions like this.  You can Use SUM over fields:

SUM(fieldname)

Or expressions containing fields:

Sum(field1 + field2)

But using SUM on expressions containing control names will cause an error.

Perhaps you can break this down into an expression using only field names (not calculated fields or controls), and as Crystal suggested, revise your query to include these.
0
SteveL13Author Commented:
My solution worked.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.