A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Sum(iif(...)) Help



 
 
Thread Tools Display Modes
  #1  
Old October 27th, 2009, 07:39 PM posted to microsoft.public.access.forms
Steve D
external usenet poster
 
Posts: 48
Default Sum(iif(...)) Help

Good Afternoon,
I am looking to do a sum if in a form footer but I keep getting the
result #ERROR. Here is the formula I have, it matched a number of responses
on this board but does not seem to work. Any help would be appreciated.

=Sum(IIf([t_Year]=2007,[Sales],0))
--
Thank You,
Steve
  #2  
Old October 27th, 2009, 07:45 PM posted to microsoft.public.access.forms
Dirk Goldgar
external usenet poster
 
Posts: 2,529
Default Sum(iif(...)) Help

"Steve D" wrote in message
...
Good Afternoon,
I am looking to do a sum if in a form footer but I keep getting the
result #ERROR. Here is the formula I have, it matched a number of
responses
on this board but does not seem to work. Any help would be appreciated.

=Sum(IIf([t_Year]=2007,[Sales],0))



Are "t_Year" and "Sales" then names of fields in the form's recordsource?
They can't just be names of controls on the form.

Are t_Year and Sales numeric fields, not text?

Make sure the name of the text box with this controlsource expression isn't
the name of any field in the form's recordsource.

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

  #3  
Old October 27th, 2009, 08:02 PM posted to microsoft.public.access.forms
Steve D
external usenet poster
 
Posts: 48
Default Sum(iif(...)) Help

They are fields in the table. t_Year is text and Sales is numeric
--
Thank You,
Steve


"Dirk Goldgar" wrote:

"Steve D" wrote in message
...
Good Afternoon,
I am looking to do a sum if in a form footer but I keep getting the
result #ERROR. Here is the formula I have, it matched a number of
responses
on this board but does not seem to work. Any help would be appreciated.

=Sum(IIf([t_Year]=2007,[Sales],0))



Are "t_Year" and "Sales" then names of fields in the form's recordsource?
They can't just be names of controls on the form.

Are t_Year and Sales numeric fields, not text?

Make sure the name of the text box with this controlsource expression isn't
the name of any field in the form's recordsource.

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

  #4  
Old October 27th, 2009, 08:56 PM posted to microsoft.public.access.forms
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Sum(iif(...)) Help

On Tue, 27 Oct 2009 13:02:01 -0700, Steve D
wrote:

They are fields in the table. t_Year is text and Sales is numeric


In that case you need the syntactically required quotemarks:

=Sum(IIf([t_Year]="2007",[Sales],0))
--

John W. Vinson [MVP]
  #5  
Old October 28th, 2009, 07:21 PM posted to microsoft.public.access.forms
Steve D
external usenet poster
 
Posts: 48
Default Sum(iif(...)) Help

I did try to use quotes but I still get #ERROR. ANy other thoughts?
--
Thank You,
Steve


"John W. Vinson" wrote:

On Tue, 27 Oct 2009 13:02:01 -0700, Steve D
wrote:

They are fields in the table. t_Year is text and Sales is numeric


In that case you need the syntactically required quotemarks:

=Sum(IIf([t_Year]="2007",[Sales],0))
--

John W. Vinson [MVP]
.

  #6  
Old October 28th, 2009, 07:50 PM posted to microsoft.public.access.forms
Dirk Goldgar
external usenet poster
 
Posts: 2,529
Default Sum(iif(...)) Help

"Steve D" wrote in message
...
I did try to use quotes but I still get #ERROR. ANy other thoughts?



What is the name of the text box containing the expression?

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

  #7  
Old October 29th, 2009, 02:31 PM posted to microsoft.public.access.forms
Steve D
external usenet poster
 
Posts: 48
Default Sum(iif(...)) Help

I didn't name it, it is still called Text48
--
Thank You,
Steve


"Dirk Goldgar" wrote:

"Steve D" wrote in message
...
I did try to use quotes but I still get #ERROR. ANy other thoughts?



What is the name of the text box containing the expression?

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

  #8  
Old October 29th, 2009, 08:54 PM posted to microsoft.public.access.forms
Dirk Goldgar
external usenet poster
 
Posts: 2,529
Default Sum(iif(...)) Help

"Steve D" wrote in message
...
I didn't name it, it is still called Text48



Please check your references to see if any of them is broken. To do that,
in the VB editor environment click Tools - References..., and look for any
referenced marked as "MISSING".

If that's not it, I'm perplexed. If you'd like to send me a cut-down copy
of your database, containing only the elements necessary to demonstrate the
problem, compacted and then zipped to less than 1MB in size (preferably much
smaller) -- I'll have a look at it, time permitting. You can send it to
the address derived by removing NO SPAM and ".invalid" from the reply
address of this message. If that address isn't visible to you, you can get
my address from my web site, which is listed in my sig. Do *not* post my
real address in the newsgroup -- I don't want to be buried in spam and
viruses.

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

  #9  
Old October 29th, 2009, 09:28 PM posted to microsoft.public.access.forms
Linq Adams via AccessMonster.com
external usenet poster
 
Posts: 1,474
Default Sum(iif(...)) Help

Is the field [Sales] a field where data is entered, or is it a calculated
field? If I remember correctly, you cannot run aggregate functions like SUM
against a field that is itself a calculated field, you have to run it against
the expression used to derive the field.

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via http://www.accessmonster.com

  #10  
Old October 29th, 2009, 10:35 PM posted to microsoft.public.access.forms
Dirk Goldgar
external usenet poster
 
Posts: 2,529
Default Sum(iif(...)) Help

"Linq Adams via AccessMonster.com" u28780@uwe wrote in message
news:9e559050b5e01@uwe...
Is the field [Sales] a field where data is entered, or is it a calculated
field? If I remember correctly, you cannot run aggregate functions like
SUM
against a field that is itself a calculated field, you have to run it
against
the expression used to derive the field.



You can't Sum a calculated *control*, but you can certainly Sum a calcuated
*field* in the form's recordsource.

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:17 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.