visible text fields

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
 
D

Dirk Goldgar

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top