title: Select ComboBox AfterUpdate Excel VBA
body: <p>I am writing a script for a <code>UserForm</code> through which users can register to gain access to a Database. The <code>UserForm</code> has three fields, <code>Username</code>, <code>Password</code> and <code>Confirm Password</code>.</p>
  
  <p>I have made it so that, after the user chooses a username, the script runs a <code>VLookUp</code> through the existing usernames to check if the username chosen already exists. If so, a <code>MsgBox</code> pops up, advising the selection of another username. In this case, all three fields of the <code>UserForm</code> are cleared. I would like to make the cursor be positioned in the <code>Username</code> field so that the user can straight away fill in a different username. However, after all fields are cleared, the <code>password</code> filed is the one selected instead. How can I solve this? Thank you for your help.</p>
  
  <p>This is the code I have written:</p>
  
  <pre><code>Private Sub usernameinput_AfterUpdate()
  
  Dim username As String
  username = usernameinput.Text
  
  Dim temp As String
  On Error Resume Next
  temp = WorksheetFunction.VLookup(Me.usernameinput.Value, Range("Usernames"), 1, 0)
  
  If username = temp Then
      MsgBox ("The username chosen already exists. Please chose a different username."), vbOKOnly + vbInformation, "Existing Username"
      Err.Clear
      temp = ""
      Me.usernameinput.Value = ""
      Me.passwordinput.Value = ""
      Me.passwordconfirm.Value = ""
      Me.usernameinput.SetFocus
      On Error GoTo 0
  End If
  
  End Sub
  </code></pre>