Sum If in footer (1 Viewer)

mtagliaferri

Registered User.
Local time
Today, 16:13
Joined
Jul 16, 2006
Messages
519
I have a form in datasheet view with multiple entries, one column named 'amount' containing amount and the other column named 'Type' containing a single letter (P as Payment and D as Deduction) the datasheet can contain payments and deductions. I need to place two unbound text boxes in the footer of the form one will have the sum of all payments and the other the sum of the deductions.
I am struggling with the formula in the Control Source, what should I have to Sum If Type equals to D or P
Thanks
 

Attachments

  • Capture.PNG
    Capture.PNG
    5.5 KB · Views: 97

CJ_London

Super Moderator
Staff member
Local time
Today, 16:13
Joined
Feb 19, 2013
Messages
16,607
try this for payment

=sum(iif([type]="P",[Amount], 0))

Note that Type is a reserved word, using it as a field name can cause unexpected and misleading errors. Strongly recommend changing it to something meaningful within the context of the app, not just the table (e.g. AmtType)

I also note your example has an unspecified Type
 

bob fitz

AWF VIP
Local time
Today, 16:13
Joined
May 23, 2011
Messages
4,721
Form footer doesn't show in datasheet form. You would need to use a Continuous form or put your Datasheet form on a new form (as a subform) and then have two text boxes on the new main form that reference the two text boxes that you have on the subform (datasheet)
 

CJ_London

Super Moderator
Staff member
Local time
Today, 16:13
Joined
Feb 19, 2013
Messages
16,607
you just have a form - which has a header and footer - but set the default view to datasheet - controls in the header and footer will still 'work'
 

bob fitz

AWF VIP
Local time
Today, 16:13
Joined
May 23, 2011
Messages
4,721
you just have a form - which has a header and footer - but set the default view to datasheet - controls in the header and footer will still 'work'
But I don't think they are visible because the header and footer aren't visible on a datasheet form.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 16:13
Joined
Feb 19, 2013
Messages
16,607
no - but on the main form you have a control to reference the subform total control - see this link for basically the same question

 

bob fitz

AWF VIP
Local time
Today, 16:13
Joined
May 23, 2011
Messages
4,721
no - but on the main form you have a control to reference the subform total control - see this link for basically the same question

I agree but isn't that what I said in post #3 :unsure:
 

CJ_London

Super Moderator
Staff member
Local time
Today, 16:13
Joined
Feb 19, 2013
Messages
16,607
I was interpreting this

Form footer doesn't show in datasheet form.

It does in design view so can be used - think just a different way of saying the same thing:)
 

mtagliaferri

Registered User.
Local time
Today, 16:13
Joined
Jul 16, 2006
Messages
519
try this for payment

=sum(iif([type]="P",[Amount], 0))

Note that Type is a reserved word, using it as a field name can cause unexpected and misleading errors. Strongly recommend changing it to something meaningful within the context of the app, not just the table (e.g. AmtType)

I also note your example has an unspecified Type

Thanks that seems to do the trick, thanks for the hint with the 'Type' field will change the name.
 

Users who are viewing this thread

Top Bottom