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  

Translate if statement in query



 
 
Thread Tools Display Modes
  #1  
Old May 27th, 2010, 10:30 PM posted to microsoft.public.access.queries
Jazz
external usenet poster
 
Posts: 53
Default Translate if statement in query

I took both of these if statements from a query in an access database and I
am trying to interpret them.

New Request: IIf(IsNull([Demand]![Average requested]),0,[Demand]![Average
requested])

Old Request: IIf(IsNull([Demand_1]![Average
requested]),0,[Demand_1]![Average requested])

My interpretation is that each statement in the query is giving a field name
to the field and then doing something or nothing depending on the data in
TABLE: Demand / FIELD: Average requested, but I am not sure what. Are you
help to help me translate these statements completely?

  #2  
Old May 29th, 2010, 08:46 PM posted to microsoft.public.access.queries
vanderghast
external usenet poster
 
Posts: 593
Default Translate if statement in query

The name at the left of the : will be the name of the field in the result,
it is called an alias, and it is used when you care about it (else, you may
get a field name like Expression005 ).

As for the expression at the right of : , they both are on the model:

iif ( IsNull(fieldName), 0, fieldName )


If you read, in the help file, about iif, you would see that it takes 3
arguments:
test,
value to be returned if the test evaluates to true
value to be returned otherwise


So, in both case, if the field value is null, it returns 0 instead of the
null, else, it returns the value of the field.


Note that a NULL is not a ZERO. A Null is used when a value is unknown,
missing, not available, not appropiate, etc. while a zero is available,
right now, as it is sure the quantity is that, zero. A database is 'fishy'
in making a difference between null and zero. Sometimes, a null may be
appropriately considered as to be zero, but then, you use a formula like the
one you saw.



Vanderghast, Access MVP



"Jazz" wrote in message
...
I took both of these if statements from a query in an access database and I
am trying to interpret them.

New Request: IIf(IsNull([Demand]![Average requested]),0,[Demand]![Average
requested])

Old Request: IIf(IsNull([Demand_1]![Average
requested]),0,[Demand_1]![Average requested])

My interpretation is that each statement in the query is giving a field
name
to the field and then doing something or nothing depending on the data in
TABLE: Demand / FIELD: Average requested, but I am not sure what. Are you
help to help me translate these statements completely?


 




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 05:39 PM.


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