validate value of text box

  • Thread starter Thread starter MFE
  • Start date Start date
M

MFE

This seems simple but I'm stuck. I want to check and see
if the value of a text box = 1, if so change the
borderstyle and borderwidth and show no value in the
textbox on the report. I tried the following code (in the
on format property of detail section of the report): (the
textbox is Box1)

If Me!Box1.Text = "1" Then
Me.Box1.BorderStyle = 3
Me.Box1.BorderWidth = 2
Me.Box1.Text = " "
End If

What's happening is every value has a bordestyle 3 and
borderwidth 2, not just when the value = 1 and if its = 1,
that value shows instead of just an empty box. Do I have
to setfocus first? when I tried just before the If
statement I got an error that property was not available
now. I'm trying in Access2000. Thanks in advance to any
assistance.
 
MFE said:
This seems simple but I'm stuck. I want to check and see
if the value of a text box = 1, if so change the
borderstyle and borderwidth and show no value in the
textbox on the report. I tried the following code (in the
on format property of detail section of the report): (the
textbox is Box1)

If Me!Box1.Text = "1" Then
Me.Box1.BorderStyle = 3
Me.Box1.BorderWidth = 2
Me.Box1.Text = " "
End If

What's happening is every value has a bordestyle 3 and
borderwidth 2, not just when the value = 1 and if its = 1,
that value shows instead of just an empty box. Do I have
to setfocus first? when I tried just before the If
statement I got an error that property was not available
now. I'm trying in Access2000. Thanks in advance to any
assistance.


You have to set it for both ways, once its set one way, it
will stay that way until you cange it to something else.
Also, you should not use the Text property (unlike VB,
Access uses the Value property).

If Me!Box1 = "1" Then
Me.Box1.BorderStyle = 3
Me.Box1.BorderWidth = 2
Me.Box1 = ""
Else
Me.Box1.BorderStyle = 1 ' or whatever
Me.Box1.BorderWidth = 0
End If
 
Back
Top