How to turn off auto save on forms?

M

Michelle

Hi All,

I need to be able to have the database not auto save when entering in new
information on a form. I would like for there to be a prompt for them to
save the information. As of now when you enter in new information and close
the form it auto saves, and this is what I am trying to avoid. Can anyone
please help with this?

Thanks
 
M

Minton M

Hi All,

I need to be able to have the database not auto save when entering in new
information on a form. I would like for there to be a prompt for them to
save the information. As of now when you enter in new information and close
the form it auto saves, and this is what I am trying to avoid. Can anyone
please help with this?

Thanks

Put this code in the BeforeUpdate event of the form:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.Dirty = True Then
If MsgBox("Do you wish to save the changes?", vbQuestion +
vbYesNo, "Save Record?") = vbNo Then
Cancel = True
Me.Undo
End If
End If
End Sub

If you don't wish to lose the data entered, just comment out the
Me.Undo statement.

Hope this helps,
James
 
D

Douglas J. Steele

That's the designed behaviour of Access, so be aware that you're trying to
do something it wasn't intended to do.

You can put code in the form's BeforeUpdate event to prompt them, and undo
the entry:

Private Sub Form_BeforeUpdate(Cancel As Integer)

If MsgBox("Do you want to save the changes?", vbYesNo) = vbNo Then
Me.Undo
Cancel = True
End If

End Sub

They'll have to try to close the form a second time, though, once the
changes have been undone. (Unless you want to the form to close everytime)
 
D

Dale Fye

Michelle,

I assume that you have the Access navigation buttons turned on. Do you have
the forms Cycle property (Other tab) set to All Records, or Current record.

I generally disable the forms navigation buttons whenever a user is entering
new or updating data. I also set the forms cycle property to "Current
Record" and disable the mouse wheel (search mouse wheel for code to do
this).

I then include Save and Cancel buttons that allow them to either save the
current record, or cancel the changes. When either of these is clicked, I
restore access to the navigation buttons. The challenge can be knowing when
to turn off the navigation buttons. The easiest way to do this is to use
the forms timer event and add some code that disables the navigation buttons
if the forms Dirty property is True. There are other ways (using the change
event of each control on the form is one) but this is the simplest.

HTH
Dale
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top