Using OR

  • Thread starter Thread starter stewart
  • Start date Start date
S

stewart

I have a form that requires the user to enter information. I want
excel to prompt the user if there is missing information. I
originally had if statements for each and every text box which seemed
excessive to me. I experimented with using or and it works for the
first part of the forma but not the second. Can I only have two
options? Any suggestions to make this work?
Here is the code:
Private Sub btnNext_Click()

'This part works
If txtEvalName.Value = "" Or txtEvalDate.Value = "" Then
GoTo d
Else
Cells(4, 7).Value = txtEvalName.Value
Cells(5, 3).Value = txtEvalDate.Value
End If

If opt6month.Value = False And opt12month.Value = False And
optSpecial.Value = False Then
GoTo d
ElseIf opt6month.Value = True Then
Cells(5, 14).Value = "6 Month Review"
ElseIf opt12month.Value = True Then
Cells(5, 14).Value = "Annual Review"
ElseIf optSpecial.Value = True Then
Cells(5, 14).Value = "Special Review"
End If

'~~~~~Employee Information~~~~~
'this does not work
If txtEmpName.Value = "" Or txtEmpPosition.Value = "" Or
txtEmpDept.Value = "" Or txtEmpResp.Value = "" Or txtHireDate.Value
Then
GoTo d
Else
Cells(3, 3).Value = txtEmpName.Value
Cells(3, 7).Value = txtEmpPosition.Value
Cells(4, 3).Value = txtEmpDept.Value
Cells(4, 14).Value = txtEmpResp.Value
Cells(3, 14).Value = txtHireDate.Value
End If

Unload Me

TCIntro.Show

Exit Sub

d: MsgBox "Please verify that all fields have been filled in and
click 'Next' again"

End Sub
 
Shouldn't...
Or txtHireDate.Value
read...
Or txtHireDate.Value = ""
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"stewart" <[email protected]>
wrote in message
I have a form that requires the user to enter information. I want
excel to prompt the user if there is missing information. I
originally had if statements for each and every text box which seemed
excessive to me. I experimented with using or and it works for the
first part of the forma but not the second. Can I only have two
options? Any suggestions to make this work?
Here is the code:
Private Sub btnNext_Click()

'This part works
If txtEvalName.Value = "" Or txtEvalDate.Value = "" Then
GoTo d
Else
Cells(4, 7).Value = txtEvalName.Value
Cells(5, 3).Value = txtEvalDate.Value
End If
If opt6month.Value = False And opt12month.Value = False And
optSpecial.Value = False Then
GoTo d
ElseIf opt6month.Value = True Then
Cells(5, 14).Value = "6 Month Review"
ElseIf opt12month.Value = True Then
Cells(5, 14).Value = "Annual Review"
ElseIf optSpecial.Value = True Then
Cells(5, 14).Value = "Special Review"
End If

'~~~~~Employee Information~~~~~
'this does not work
If txtEmpName.Value = "" Or txtEmpPosition.Value = "" Or
txtEmpDept.Value = "" Or txtEmpResp.Value = "" Or txtHireDate.Value Then
GoTo d
Else
Cells(3, 3).Value = txtEmpName.Value
Cells(3, 7).Value = txtEmpPosition.Value
Cells(4, 3).Value = txtEmpDept.Value
Cells(4, 14).Value = txtEmpResp.Value
Cells(3, 14).Value = txtHireDate.Value
End If
Unload Me
TCIntro.Show
Exit Sub
d: MsgBox "Please verify that all fields have been filled in and
click 'Next' again"
End Sub
 
Yes it should. I can't believe I missed it. Thanks for catching
that.
 

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

Back
Top