title: Updating/adding entry to table only when question is answered?
body: <p>I'm setting up a database in MS Access 2013, and want to ask the user a yes/no if they want to save or discard their non-saved record or edit before navigating away from the current record in my Access form. </p>
  
  <p>The user should not be met with the question if pressing either the "add record" or "save" buttons. </p>
  
  <p>Can someone point to where my problematic code is / or what I need? </p>
  
  <p>Also, I'm new to Access, so please be gentle.</p>
  
  <p>I have tried a few different guides or other answers around the web, but haven't gotten exactly to where I want to be. </p>
  
  <p>My code is as such (cbotxt_Change and Form_Load relate to other parts of the form)</p>
  
  <pre><code>Private blnGood As Boolean
  
  Option Compare Database
  
  Private Sub cbotxt_Change()
      Me.txt1.Value = Me.test1.Column(2)
      Me.txt2.Value = Me.test1.Column(3)
      Me.txt3.Value = Me.test1.Column(4)
  End Sub
  
  Private Sub Form_Load()
      DoCmd.GoToRecord , , acNewRec
  End Sub
  
  Private Sub button_addRecord_Click()
      blnGood = True
      DoCmd.GoToRecord , , acNewRec
      blnGood = False
  End Sub
  
  Private Sub Form_BeforeUpdate(Cancel As Integer)
      Dim strMsg As String
  
      If Not blnGood Then
          strMsg = "want to abort?"
          If MsgBox(strMsg, vbYesNo + vbQuestion, "Yes") = vbYes Then
              Me.Undo
          Else
              Yes = True
          End If
      End If
  End Sub
  </code></pre>
  
  <p>Using the code above, "want to abort?" is asked whenever the user is attempting to navigate away from the current record + when "add record" or "save" buttons are pressed. If the user answers "No", then the entry will save and the action in question be performed, except the "add record" button, which only seems to save now, not add a new record.</p>