Cant Make Label Visible If ???

  • Thread starter Thread starter Dave Elliott
  • Start date Start date
D

Dave Elliott

Text430 simply shows a number, i.e. 55

If Text430.Value <= "55" Then
Lbl6.Visible = True
Else:
Lbl6.Visible = False
End If
 
If you intend Access to perform a numeric comparison, lose the quotes, i.e.:
If Text430.Value <= 55 Then

With the quotes, it will most likely perform a string comparison, i.e.
character by character. As a result, "11" is less than "2" (because the
first character - 1 - is less than the first character of the other string -
2.)

If Text430 is bound to a Text type field, Access may still perform a string
comparison. If it is unbound, set its Format property to General Number so
Access knows you want the value treated as a number (and it won't let you
enter non-numeric values.)

For a solution without code, replace right-click lbl6 and Change To | Text
box. Then set its Control Source to:
=IIf([Text430] < 55, "Some text", Null)
 
Dave Elliott said:
Text430 simply shows a number, i.e. 55

If Text430.Value <= "55" Then
Lbl6.Visible = True
Else:
Lbl6.Visible = False
End If

Does it work if you ditch the quotes:

If Text430.Value <= 55 Then

? If you want a numeric comparison, you'd better compare to a number,
not a string.

If that doesn't fix it, you'd better give more background, including
where exactly this code is being executed, and whether you've verified
that the code is, in fact, being called.
 
Text430 simply shows a number, i.e. 55

If Text430.Value <= "55" Then
Lbl6.Visible = True
Else:
Lbl6.Visible = False
End If

Well, lose the quotes - the text string "1291455" is "less" than the
text string "55" (just as the text string "zbig" is "less" than "ee").

The other issues is where you put this code - I'd suggest in both the
Form's Current event and the AfterUpdate event of Text430.

Also it's just Else not Else:


John W. Vinson[MVP]
 
Dave,
In addition to Alan and Dirks' response...
I think the
Else:
should be just
Else

"Else:" would be recognized by Access as a "line address" (used with a
GoTo statement.)
hth
Al Camp
 
Al Camp said:
Dave,
In addition to Alan and Dirks' response...
I think the
Else:
should be just
Else

"Else:" would be recognized by Access as a "line address" (used
with a GoTo statement.)
hth
Al Camp

You and John have sharper eyes than I do. Well spotted.
 
Back
Top