| | |
|
|
|
IIF Statement |
| message from =?Utf-8?B?YmRlaG5pbmc=?= on 10 May 2004 |
How would one write the IIF statement for the following?
If a check box is selected on a form and tied to a field cancel and I would like to produce the words cancel in a report.
Also if a date field is entered for the field rescheduled how do I show the words rescheduled instead of the dates for the original field.
I am new to IIF Statements.
|
| John Vinson replied to =?Utf-8?B?YmRlaG5pbmc=?= on 10 May 2004 |
Do you want the words "Cancel" and "Reschedule" in the same textbox,
or different textboxes? I take it that the field [Rescheduled] is a
Date/Time field? What do you want to see if Canceled is checked, and
there is also a date in Rescheduled (I presume this would be an
error)?
Here's a possible suggestion, making some assumptions about what you
want: set the Control Source of a textbox to
=IIF([Cancel], "Cancel", IIF(IsNull([rescheduled]), "",
"Rescheduled"))
This uses nested IIF's - the way an IIF works is that it has three
arguments. The first is a logical expression which evaluates to either
TRUE or FALSE; if it's TRUE, the IIF() function returns the second
argument; if it's FALSE it returns the third. Here, if the Yes/No
field [Cancel] is true it returns a text string "Cancel"; if it's
false, it returns the result of the inner IIF() statement. IsNull() is
a builtin function which returns TRUE if its argument is NULL, FALSE
if it's not - so you'll get an empty string or the word Rescheduled as
needed.
John W. Vinson[MVP]
Come for live chats every Tuesday and Thursday
http://go.compuserve.com/msdevapps?loc=us&access=public
|
| fredg replied to =?Utf-8?B?YmRlaG5pbmc=?= on 10 May 2004 |
Not too sure I understand what you are saying, BUT ...
If you have a field named [Cancel], and you want to actually print
"Cancel" in a report if the value of the field is True (-1), then:
Add an unbound control to the report.
Set it's control source to:
=[Cancel]
Set it's Format property to:
;"Cancel";
It will print "Cancel" if the value is True (-1), otherwise nothing.
See Access Help on
Format Property + Number and Currency datatypes
To print "Rescheduled" if a date has been entered into a field instead
of the date, add an unbound control to the report.
Set it's control source to:
=IIf(IsNull([DateField]),"","Rescheduled")
|
| =?Utf-8?B?YmRlaG5pbmc=?= replied to fredg on 10 May 2004 |
Thank you for the help with writing the IIF Statement.
My problem will ultimately how to turn all the iif statements results into one column under Status for a report as each of the areas where I need words to print instead of dates occurs on several forms.
I am not sure how to bring all the data back together into one column .
I will have a date field for rescheduled, date field for completed and check box for Waived and Cancelled. All are assumed to be Outstanding until the fields are entered as needed on forms.
|
|
Archived message: IIF Statement (MS Access)