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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|