visible text fields

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a 2 text boxes that i need to be visible when the text entered in a
3rd text box is 78999 or 77000. The code worked when i had only one
condition, but the code below doesn't work, any text entered makes the 2 text
boxes visible. Any help is much appreciated.

Private Sub txtAcctNo_AfterUpdate()
If txtAcctNo.Value = "78999" Or "77000" Then
txtAcctName.Visible = True
txtPolNo.Visible = True

Else: txtAcctName.Visible = False
txtPolNo.Visible = False

End If

End Sub
 
In
efua20 said:
I have a 2 text boxes that i need to be visible when the text entered
in a 3rd text box is 78999 or 77000. The code worked when i had only
one condition, but the code below doesn't work, any text entered
makes the 2 text boxes visible. Any help is much appreciated.

Private Sub txtAcctNo_AfterUpdate()
If txtAcctNo.Value = "78999" Or "77000" Then
txtAcctName.Visible = True
txtPolNo.Visible = True

Else: txtAcctName.Visible = False
txtPolNo.Visible = False

End If

End Sub

In making a logical "Or" expression, you need to restate the subject of
the comparison both times. Try it like this:

If txtAcctNo.Value = "78999" _
Or txtAcctNo.Value = "77000" _
Then

Note that I broke that onto multiple lines with continuation characters,
just for clarity and to avoid confusion when the newsreader posts it.
It could just as easily be all on one line:

If txtAcctNo.Value = "78999" Or txtAcctNo.Value = "77000" Then
 
Back
Top