Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


IIF to do NOTHING if false.

Posted on 2004-11-16
Medium Priority
Last Modified: 2012-06-27
this is pretty simple, or so I thought... I have a 2 text boxes with the following control source

=IIF([Month]='10/1/2003',[SumOfYTD Life])

=IIF([Month]='10/1/2004',[SumOfYTD Life])

I have 2 records in the report. One record has a date of 10/1/2003 the other 10/1/2004.

All I want to do is to have it evaluate and then set the boxes to the value as outlined in the IIF. The problem is that when it evaluates the expression for the second record, it finds it false and wipes out the value from the first record.

Is there any way to have the IIF do NOTHING if FALSE.....Absolutely nothing....I don't want the value to change. I will use the value later.

I have tried everything....I even tried SWITCH([Month]='10/1/2003',[SumOfYTD Life]).....It still evaluated and changed the value of the box.

please HELPPPP ME....
Question by:mflatford

Expert Comment

ID: 12598589
IIf(expr, truepart, falsepart)

=IIF([Month]='10/1/2004',[SumOfYTD Life],[Month])


Author Comment

ID: 12598778
Good try... Not the right answer..... I don't want ANYTHING in the field except for the record that has the date 10/1/2004....

With the above, it would give my box the value of [Month] if false. I want it to do NOTHING if false... in other words, do not change the value. leave it as is...I don't want it null... I don't want a zero, I want it whatever value it was before the expression was evaluated. Therefore left UNCHANGED if false.... only change it if the expression is true.

Accepted Solution

Plamodo earned 500 total points
ID: 12606036
If I understand your problem correctly.. You want a textbox to change if it meets a certain criteria, but if it doesn't meet that criteria, you want it be [SumOfYTD] in the previous record.  To do this, we'll have to keep track of what your textbox *used* to be before you moved to the next (or previous) record.

Lets just deal with your first textbox for the moment to keep things simpler.  In this example, I call the first textbox: txtStatus.
1)Create another textbox called txtPrevStatus which is to be an unbound (nothing in the control source), hidden textbox.
2)Change the control source of txtStatus to:  =getStatus()
3)Insert the following code into the module code for this form:

Private Function getStatus()
    If [Month] = '10/1/2003' Then
        txtPrevStatus.Value = [SumOfYTD]
    End If
    getStatus = txtPrevStatus.Value
End Function

4)All we need to figure out now is what do you want the value of txtStatus to be if the first record (when the form loads) doesn't match the criteria.

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question