Question : 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....

Answer : IIF to do NOTHING if false.

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.
Random Solutions  
 
programming4us programming4us