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  

IF function in Query



 
 
Thread Tools Display Modes
  #1  
Old May 8th, 2008, 10:46 PM posted to microsoft.public.access.queries
Supe
external usenet poster
 
Posts: 146
Default IF function in Query

Can an IF function be used in a Query? I set up the IF function below to use
in an Excel worksheet to list the Banner name by searching for a name within
the store name field. My plan was to export the query into an Excel sheet,
but it exceeds the maximum number of lines allowed(Excel 2003). Can this IF
function be set up in the query so that it can determine the banner in the
query?


=IF(COUNTIF(A3,"*Shopper*"),"Shoppers",IF(COUNTIF( A3,"*Cub*"),"Cub",IF(COUNTIF(A3,"*Farm Fresh*"),"Farm Fresh",IF(COUNTIF(A3,"*Bigg*"),"Biggs"," "))))
  #2  
Old May 8th, 2008, 10:57 PM posted to microsoft.public.access.queries
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default IF function in Query

Looks like you want nested IIF statement but have wrong syntax.
IIF([YourFieldName] test, True answer, False answer)

Try this --
IIF([YourField] Like "*Shopper*","Shoppers", IIF([YourField] Like
"*Cub*","Cub", IIF([YourField] Like "*Farm Fresh*","Farm Fresh",
IIF([YourField] Like "*Bigg*","Biggs"," "))))

--
KARL DEWEY
Build a little - Test a little


"Supe" wrote:

Can an IF function be used in a Query? I set up the IF function below to use
in an Excel worksheet to list the Banner name by searching for a name within
the store name field. My plan was to export the query into an Excel sheet,
but it exceeds the maximum number of lines allowed(Excel 2003). Can this IF
function be set up in the query so that it can determine the banner in the
query?


=IF(COUNTIF(A3,"*Shopper*"),"Shoppers",IF(COUNTIF( A3,"*Cub*"),"Cub",IF(COUNTIF(A3,"*Farm Fresh*"),"Farm Fresh",IF(COUNTIF(A3,"*Bigg*"),"Biggs"," "))))

  #3  
Old May 9th, 2008, 01:46 PM posted to microsoft.public.access.queries
Supe
external usenet poster
 
Posts: 146
Default IF function in Query

That did it. Thank you very much.


"KARL DEWEY" wrote:

Looks like you want nested IIF statement but have wrong syntax.
IIF([YourFieldName] test, True answer, False answer)

Try this --
IIF([YourField] Like "*Shopper*","Shoppers", IIF([YourField] Like
"*Cub*","Cub", IIF([YourField] Like "*Farm Fresh*","Farm Fresh",
IIF([YourField] Like "*Bigg*","Biggs"," "))))

--
KARL DEWEY
Build a little - Test a little


"Supe" wrote:

Can an IF function be used in a Query? I set up the IF function below to use
in an Excel worksheet to list the Banner name by searching for a name within
the store name field. My plan was to export the query into an Excel sheet,
but it exceeds the maximum number of lines allowed(Excel 2003). Can this IF
function be set up in the query so that it can determine the banner in the
query?


=IF(COUNTIF(A3,"*Shopper*"),"Shoppers",IF(COUNTIF( A3,"*Cub*"),"Cub",IF(COUNTIF(A3,"*Farm Fresh*"),"Farm Fresh",IF(COUNTIF(A3,"*Bigg*"),"Biggs"," "))))

 




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 01:45 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.