How does Access remind you if you want to save the changes made?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Say if I accidentally made some changes on a cell content in a table in
Access, the whatever changes I made will be saved automatically when I exit
the table. Is there a way that Access will act like Word or Excel asking you
if you want to do "save" or "save as" when you are exitting a table or form?
 
Access saves each record, as you move from row to row in your table. It is
not possible to set up the table so that it saves all the records you
changed only when you close the table.

If you want confirmation to save each record, use a form - in Datasheet view
if you want it to look like a table. You can add some code to the
BeforeUpdate event procedure of the form that will ask for confirmation for
each record. The code for the event procedure would look like this:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If MsgBox("Save?", vbOkCancel, "Confirm") <> vbOk Then
Cancel = True
'Me.Undo
End If
End Sub
 
Thanks for the help. I really appreciate it.
I guess I'm new to the database development. So my further question is how
do I add the BeforeUpdate event procedure into a form?
 
1. Open the form in design view.

2. Open the Properties box. (View menu.)

3. Make sure the Title bar of the Properties sheet reads "Form", so you are
looking at the properties of the form, not those of a text box.

4. On the Event tab, locate the Before Update property.

5. Set the property to:
[Event Procedure]

6. Click the Build button (...) beside this.
Access opens the code window.

7. Set up the code in there as shown.
 
Back
Top