PDA

View Full Version : Solved: acSavePrompt not working



cath_hopes
10-07-2007, 10:15 PM
Hi there, I'm new to Access and using Access 2007. I've added the following code to my 'Close Form' button:
Private Sub Close_Form_Click()
DoCmd.Close acForm, "Property Form", acSavePrompt
End Sub
The form closes but doesn't offer the user a Save Prompt. Can anyone advise? Thanks!

OBP
10-08-2007, 03:49 AM
It doesn't in Access 2000 either.

icthus123
10-10-2007, 05:24 AM
Hi there, I'm new to Access and using Access 2007. I've added the following code to my 'Close Form' button:
Private Sub Close_Form_Click()
DoCmd.Close acForm, "Property Form", acSavePrompt
End Sub
The form closes but doesn't offer the user a Save Prompt. Can anyone advise? Thanks!

As far as I'm aware acSavePrompt is about changes on the form not the recordset. So if you haven't made any changes to the form design it won't appear, if, however, you do it should.

Whenever you move off a record, or close a form, the record should be saved automatically, so you don't need to worry about saving. However if you think sometimes you might want to delete a record you might be better with a delete record button on the form, something like this:


If Me.NewRecord = True Then
Me.Undo
Else
DoCmd.RunCommand acCmdDeleteRecord
End If


This should work on whichever record you happen to be on.

cath_hopes
10-10-2007, 06:19 AM
Thank you icthus123!! And you must have read my mind because I've also been looking for the Delete record command! I have used your code along with a close command and all works fine now.