title: Excel VBA - Calling TextBox Exit Event on Userform manually?
body: <p>I'm building a userform where it has two text boxes to enter dates. Once the date is entered, I'm validating them when the <code>Exit</code> event fires. If the validation turns up that the user data isn't what is needed, the user is notified, the text box is cleared, and the focus is returned back to the textbox.</p>
  
  <p>The issue comes if the user uses the mouse to select outside of the box, rather than Tab. If Tab is used, it fires perfectly and as expected, and the field is cleared and the focus is returned. If the mouse is used, it doesn't fire. According to <a href="https://msdn.microsoft.com/en-us/library/office/ff844925.aspx" rel="nofollow noreferrer">this article</a>, this is expected behavior (It's for Access, but I didn't see the similar relevant MSDN article for Excel.)</p>
  
  <p>So instead I tried the <code>AfterUpdate</code> event. However, <code>SetFocus</code> doesn't work within an <code>AfterUpdate</code> event, I'm assuming because of the chain of events as outlined in the response to <a href="https://stackoverflow.com/questions/18990437/why-is-my-setfocus-ignored">this question</a>. Thus, I don't have a way to return the focus back to the textbox after it has fired. That thread had a suggestion as an alternate answer to <code>SetFocus</code> to another control and come back as a workaround, but that doesn't work for me, so I assume that may be an Access-specific workaround.</p>
  
  <p>My last option I've considered is having the <code>AfterUpdate</code> event just call the <code>Exit</code> event, however the <code>Exit</code> event has a required argument <code>(ByVal Cancel As MSForms.ReturnBoolean)</code>, which is how you cancel out of the exit and return the user to the textbox. As such, there isn't a value that you can pass to it that doesn't throw an error that I can find (the closest I found was passing <code>Nothing</code> but it failed out when trying to set it to <code>True</code> later to cancel the exit.)</p>
  
  <p>Is there a way to achieve what I'm looking for here, or should I just stick to the <code>AfterUpdate</code> and ignore the <code>SetFocus</code> I'm trying to achieve?</p>