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 » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

iif statement



 
 
Thread Tools Display Modes
  #1  
Old November 9th, 2009, 05:35 PM posted to microsoft.public.access.queries
jligue
external usenet poster
 
Posts: 1
Default iif statement

I am new to access; trying to create a query for a report that has a subtotal,
the field will only total if a portion of a word appears in a combo box of
another field. Specifically, if the Product Type field (which is a combo box)
has the word "bag" in it, I want the value in the Qty field to be counted.
If the word "bag" is not in the Product Type field, then no value is
populated in the newly created field. Ultimately a final subtotal will be
needed for the report.

  #2  
Old November 9th, 2009, 06:14 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default iif statement

You would need an expression something like the following as a control's
control source
=SUM(IIF(" " & [Product Type] & " " Like "* BAG *",Qty,Null))

or you could use a calculated field in the query and then sum it in the report.

Field: BAGQty: IIF(" " & [Product Type] & " " Like "* BAG *",Qty,Null)


John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County

jligue wrote:
I am new to access; trying to create a query for a report that has a subtotal,
the field will only total if a portion of a word appears in a combo box of
another field. Specifically, if the Product Type field (which is a combo box)
has the word "bag" in it, I want the value in the Qty field to be counted.
If the word "bag" is not in the Product Type field, then no value is
populated in the newly created field. Ultimately a final subtotal will be
needed for the report.

 




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 08:16 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.