If-Then Conditional Formatting

indyaries

Registered User.
Local time
Today, 12:44
Joined
Apr 22, 2002
Messages
102
Greetings,

I am using Access 97. I have a calculated field in a query called Variance. This field does not exist in the main table.
I have placed this field on a form, and am attempting to perform some conditional formatting.

What I'm trying to do is get a label called label_ExcessiveVariance to be visible when the VARIANCE is greater than or less than $500.

I created the label, calling it label_ExcessiveVariance. It's visible property is set to No.

In the OnCurrent event of the FORM, I have placed this code;

' If the calculated control Variance is <> $500, then display the hidden label. 06-26-02
If [Variance] <> 500 Then
Me![label_ExcessiveVariance].Visible = True
Else
Me![label_ExcessiveVariance].Visible = False
End If

This code does not work. The label is visible at all times. When I change the greather than-Less than to just Greater Than, it works fine. Same with only Less Than.

I've used this type of code before to set the visible properties on Forms and Reports. It's vexing me that it's not working correctly here.

Thanking one and all for any assistance received.

Bob
 
If [Variance]= 500 Then
Me![label_ExcessiveVariance].Visible = False
Else
Me![label_ExcessiveVariance].Visible = True
End If
 
Rich,

Thank you for your reply. However, what I'm trying to do is arrive at a number greater-than or less-than a $500 variance.

Example 1:
Estmated Travel Amount: $700.00
minus Actual Voucher Amount: $975.00
Variance: $-275.00

In this example, the label would not show...same thing with the variance being positive $275.

But, if the variance was greater than or less than $500 -- meaning if the variance was greater than positive $500 or less than negative $500, I would like the label to appear.

Thanks again, Rich, and to one and all who reply.

I love this site !!!!!

Bob
 
Will this work?
If Abs([Variance])> 500 Then
Me![label_ExcessiveVariance].Visible = True
Else
Me![label_ExcessiveVariance].Visible = False
End If
 
Rich,

That was right on the money !! I don't think I would have ever thought of the ABS answer.

Thank you very much, and thank God for this website!

Sincerely,

Bob
Indianapolis, Indiana, USA
 

Users who are viewing this thread

Back
Top Bottom