IIF to do NOTHING if false.

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....
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

IIf(expr, truepart, falsepart)

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

mflatfordAuthor Commented:
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.
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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.