Issue when summing fields containing Iif expression

howardt

New Member
Joined
Nov 15, 2005
Messages
11
Ok, long time viewer, first time poster:

I have a list of Bank presentations, each has a specific dollar amount.

Before the Presentation is accepted by the bank the Amount Accepted field returns 0.00.

When it is accepted the Accepted? field is checked and the Amount Accepted field returns the specific amount for that Presentation. This bit is fine and is done by the expression:

Amount Accepted = IIf(([Accepted?])=Yes,[Amount],0)

The issue arises when I need to sum the all the Amount Accepted values. Hence when I have my calculated control in the footer of the subform with expression:

SumofPresentations = Sum([Amount Accepted])

It returns #Error. The eternal question: WHY?


ta,

ht
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Andrew Fergus

MrExcel MVP
Joined
Sep 9, 2004
Messages
5,449
Office Version
  1. 365
  2. 2021
  3. 2016
Platform
  1. Windows
Hello and welcome to MrExcel.

I haven't tested this but have you tried using something like this:

=Sum(IIf([Accepted?],[Amount],0))

HTH, Andrew :)
 

howardt

New Member
Joined
Nov 15, 2005
Messages
11

ADVERTISEMENT

Hi Andrew,

Your code works fine in the subform to give me what I need
=Sum(IIf([Accepted?]=Yes,[Amount],0))

Then when I try to repeat the calculation in the main form with:
=Sum(IIf([Presentations subform].Form![Accepted?]=Yes,[Presentations subform].Form!Amount,0)).

I get my same old #Error. Any ideas why?
 

Andrew Fergus

MrExcel MVP
Joined
Sep 9, 2004
Messages
5,449
Office Version
  1. 365
  2. 2021
  3. 2016
Platform
  1. Windows
Hi

You can't directly reference the items on the subform like that but you can reference the total on the subform. To see how to do this, follow this link for a full blown explanation.

HTH, Andrew :)
 

howardt

New Member
Joined
Nov 15, 2005
Messages
11
Andrew,

Thanks for your help, the issue was confused as I hadn't told the form to refresh.

All done to my satisfaction now though.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,995
Messages
5,834,778
Members
430,321
Latest member
yemisimi11

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top