Hello!
Edit: Apologies, incorrect posting title
I created an IF statement to display a MsgBox if both a Combo Box and Text Box were filled. The MsgBox comes up with no issues, however once you click "Ok" on the MsgBox, instead of taking you back to the Userform like I want it to, it cycles through the rest of the code and opens up the next form. Is there a way that after clicking Ok on the MsgBox, it just takes you back to the same form so you can edit the Userform?
Edit: Apologies, incorrect posting title
I created an IF statement to display a MsgBox if both a Combo Box and Text Box were filled. The MsgBox comes up with no issues, however once you click "Ok" on the MsgBox, instead of taking you back to the Userform like I want it to, it cycles through the rest of the code and opens up the next form. Is there a way that after clicking Ok on the MsgBox, it just takes you back to the same form so you can edit the Userform?
VBA Code:
Private Sub CommandButton1_Click()
'Check to see if Valid search entries
If ComboBox1.Value <> "" And Trim(TextBox1.Text) <> "" Then
MsgBox "Please use the drop down menu OR the Last Name text box. You cannot search using both."
ElseIf ComboBox1.Value = "" And Trim(TextBox1.Text) = "" Then
MsgBox "Invalid parameters."
Else
'Write data to cell for lookup later
If ComboBox1.Value <> "" Then
Range("FullNameLookUp").Value = ComboBox1.Value
Else
Range("LastNameLookUp").Value = TextBox1.Value
End If
End If
Unload Me
With EmployeeLookup
.StartUpPosition = 0
.Left = Application.Left + (0.5 * Application.Width) - (0.5 * .Width)
.Top = Application.Top + (0.5 * Application.Height) - (0.5 * .Height)
.Show
End With
End Sub