title: Check if field is null or blank before closing form on Access using VBA
body: <p>I've been playing around this with VBA code to check if the field is empty before closing the form. If the field is empty, I want it to display a Yes/No message box. 
  The issue that I'm having is that when I click <code>No</code> after the message appears (if the field is blank), it continues to close the form. Instead, when I click <code>No</code>, I want the focus to set on the field that needs to be addressed.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>Private Sub Close_Click()
  
  If IsNull(cboTxtBx) Then
          MsgBox("Do you want to continue?", vbYesNo, "X is Blank!")
          If vbYes Then
              DoCmd.Close
          Else
              cboTxtBx.SetFocus
          End If
  Else
      DoCmd.Close
  End If
  
  End Sub
  </code></pre>
  
  <p>I've also replaced <code>IsNull()</code> with <code>Len(cboTxtBx.value &amp; "") = 0</code> and still have the same issue.<br>
  I've also removed the last <code>DoCmd.Close</code> statement but the form still closes once I hit <code>No</code>.</p>
  
  <p>I'm sure the solution lies within the sequence of my code but I'm not proficient with VBA and I'm struggling to get this code to work. </p>
  
  <p>One small note, <code>cboTxtBx</code> is a combo box. Not sure if that interrupts the code in any way. </p>