title: VBA - Error 3167 Record deleted
body: <p>I know there's similar posts as this one, but i have not managed to resolve my error by reading them, so i'm posting. </p>
  
  <p>I m trying to make an input form in Ms Access, the user will input two barcodes, and then he ll press a button to commit those values to a table, the process will be repeated until he needs to store said table, in which case there's another button event for that. When they enter each set of records to the input boxes and hit commit, the record is saved, and all the fields are cleared, cursor is going to barcode1 field to await new entries.</p>
  
  <p>The problem starts when, after one successful execution of everything, if i rerun the database, and restart everything, when i try to press the button to commit a new entry into the table, i get the following error:</p>
  
  <blockquote>
    <p>Error 3167: Record is Deleted</p>
  </blockquote>
  
  <p>If i close (x) the application and restart it, everything works normally again. </p>
  
  <p>Here's the relevant code, with the point the debugger gives me the error:</p>
  
  <pre><code>Private Sub CommitButton_Click()
  
      'If (Me!Barcode1 = "**************************") Or IsNull(Me!Barcode1) Or IsNull(Me!Barcode2) Then
      'If (Len(Me!Barcode1) &lt; 2) Or (Len(Me!Barcode2) &lt; 2) Then
      len_barcode1 = Len(Me!Barcode1)
      len_barcode2 = Len(Me!Barcode2)
  
      If (len_barcode1 &lt; 1 Or IsNull(len_barcode1)) Or (len_barcode2 &lt; 1 Or IsNull(len_barcode2)) Then
          MsgBox ("IS NULL - NOT SAVING")
      Else
         MsgBox ("IS NOT NULL - SAVING")
  
         fld2 = Barcode2.Value
         fixed = Mid(fld2, 6, 14)
         Barcode2.Value = fixed
  
         'DoCmd.SetWarnings (WarningsOff)
         DoCmd.RunCommand acCmdSaveRecord
         DoCmd.GoToRecord acDataForm, "BarCodeDataForm", acNext, 1
         Me.Barcode1.SetFocus
         'DoCmd.SetWarnings (WarningsOn)
         Me.Barcode1.Value = Null
         Me.Barcode2.Value = Null
         Me.ValuePrice.Value = Null
         Me.Barcode1.SetFocus    
  
      End If
  End Sub
  </code></pre>
  
  <p>As you see, there is a manual change to a value (Barcode2), the error appears on exactly the next line:</p>
  
  <pre><code>DoCmd.RunCommand acCmdSaveRecord
  </code></pre>
  
  <p>Is there a way to commit the changes or resolve this? Thank you</p>