ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using OR (https://www.excelbanter.com/excel-programming/385930-using.html)

stewart

Using OR
 
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


Jim Cone

Using OR
 

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



"stewart"
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


stewart

Using OR
 
Yes it should. I can't believe I missed it. Thanks for catching
that.

On Mar 22, 10:22 pm, "Jim Cone" wrote:
Shouldn't...
Or txtHireDate.Value
read...
Or txtHireDate.Value = ""
--
Jim Cone
San Francisco, USAhttp://www.realezsites.com/bus/primitivesoftware

"stewart"
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





All times are GMT +1. The time now is 07:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com