total amt in subform

J

JohnE

Hello. I have a subform that is the many to the main forms one. One field
on the subform in the footer is a textbox that provides a total of a field in
the subform. This works fine. What I am doing now is adding another field
to the subform footer to provide a total of the same field but only if a
combobox in the subform has a specific value in it. Now, I am confused and
seek assistance from the newsgroup. Appreciate any assistance.
*** John
 
D

Duane Hookom

"if a combobox in the subform has a specific value in it"
Is the combo box bound to a field in the subform's record source?

Generically, you can use an expression like:

=Sum(Abs([SomeField]="a specific value") * [FieldToSum])

If SomeField is numeric, remove the quotes from around "a specific value".
 
J

John Vinson

Hello. I have a subform that is the many to the main forms one. One field
on the subform in the footer is a textbox that provides a total of a field in
the subform. This works fine. What I am doing now is adding another field
to the subform footer to provide a total of the same field but only if a
combobox in the subform has a specific value in it. Now, I am confused and
seek assistance from the newsgroup. Appreciate any assistance.
*** John

I'd suggest you add a calculated Field in the query upon which the
form is based. You can't sum *controls* on a Form; you can sum *values
in a field*. If you put a calculated field in the Query such as

ConditionalSum: IIF([otherfield] = "Foo", [sumfield], 0)

and put

=Sum([ConditionalSum])

in the subform footer, it will sum only those rows where the
otherfield (the one you're using with the combo box) is equal to
"foo".

John W. Vinson[MVP]
 

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