I am trying to use the if function on my userform to only allow certain values to be returned from the input of other values on the userform. I also want a message box to appear if certain fields are left blank based upon which data has been entered. Here is my code, but even when I have data input into the "Valve Position" combo box it still tells me "Data needed" Why?
Here is just an excerpt of my code:
If Me.ComboBox_Isolationtype.Value = "" Then
MsgBox "Please enter data", vbExclamation, "Isolation Data Needed"
Me.ComboBox_Isolationtype.SetFocus
Exit Sub
End If
If Me.TextBox_Material.Value = "" Then
MsgBox "Please enter data", vbExclamation, "Isolation Data Needed"
Me.TextBox_Material.SetFocus
Exit Sub
End If
If Me.TextBox_IsolationLocation.Value = "" Then
MsgBox "Please enter data", vbExclamation, "Isolation Data Needed"
Me.TextBox_IsolationLocation.SetFocus
Exit Sub
End If
If Me.ComboBox_Isolationtype.Value = "Valve" Or Me.ComboBox_Isolationtype.Value = "Electrical" Or Me.ComboBox_Isolationtype.Value = "Air Mover" Or Me.ComboBox_Isolationtype.Value = "ARP Valve" Or Me.ComboBox_Isolationtype.Value = "Globe Valve" And Me.ComboBox_Valveposition.Value = "" Then
MsgBox "Please enter data", vbExclamation, "Isolation Data Needed"
Me.ComboBox_Valveposition.SetFocus
ElseIf Me.ComboBox_Isolationtype.Value = "Valve" Or Me.ComboBox_Isolationtype.Value = "Electrical" Or Me.ComboBox_Isolationtype.Value = "Air Mover" Or Me.ComboBox_Isolationtype.Value = "ARP Valve" Or Me.ComboBox_Isolationtype.Value = "Globe Valve" Then
Me.ComboBox_Valveposition.Value = "Closed" Or Me.ComboBox_Valveposition.Value = "Opened"
Exit Sub
End If
If Me.ComboBox_Type.Value = "" Then
MsgBox "Please enter data", vbExclamation, "Isolation Data Needed"
Me.ComboBox_Type.SetFocus
Exit Sub
End If
Any advice?
Thanks in advance.
Bookmarks