I'm looking for a couple different solutions (if available) to prevent data entered through a bound form from automatically adding the record to the table it is bound to, until the "add record" button has been clicked?
I'm looking for a couple different solutions (if available) to prevent data entered through a bound form from automatically adding the record to the table it is bound to, until the "add record" button has been clicked?
You're trying to reinvent the way Access is intended to work, and this becomes a problem with experienced Access data input users. They know that Access saves records when moving to another record or when the form is closed, and expect this behavior. In my opinion, it's a better policy to allow Access to work in its native way and merely check with the user before the record is saved, allowing them to save it or dump the new record or changes. This piece of code will do just that
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Not (Me.NewRecord) Then
If MsgBox("Would You Like To Save The Changes To This Record?", vbQuestion + vbYesNo + vbDefaultButton1, "Save Changes to Record ???") = vbNo Then
Me.Undo
End If
Else
If MsgBox("Would You Like To Save This New Record?", vbQuestion + vbYesNo + vbDefaultButton1, "Save This Record ???") = vbNo Then
Me.Undo
End If
End If
End Sub
You can still add a "Save" button, if some users expect it, merely having it set up to move to a new record. The users will still be asked to confirm the save, from the code above, but experienced Access users can run the app the way they know Access is intended to work.