Solved

How to add a "Confirm Changes?" message prompt to a form before saving the record?

Posted on 2003-12-08
3
341 Views
Last Modified: 2012-06-27
I have a record entry form for users to fill in.  I have added a confirmation prompt to confirm that their record has been saved, but I now would like to initially prompt the user to ensure they are happy with their finished record before committing to saving it.

I ideally want a msgbox prompter to offer the options:

1. YES - Saves the record and resets (blanks) the form fields, then gives the confirmation prompt.
2. NO - Reverts the user back to the form WITHOUT SAVING, allowing the User to make other edits to the unsaved record before trying to save again.
0
Comment
Question by:Lukasx
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 125 total points
ID: 9895447
If you are either just moving from one record to another or closing the form to force a save then you can use the Form_Beforeupdate event procedure to control the save.

The beforeupdate event has a Cancel option.  If you set this to true the save is cancelled.

Private Sub Form_beforeupdate(Cancel As Integer)
Dim resp
resp = MsgBox("Do you wish to Save the record?", vbYesNo + vbQuestion, "Save Changes")
If resp = vbYes Then
' do nothing
Else
Cancel = True  ' cancels the update
End If

End Sub

However if you are using a Save button then you just bypass the saverecord statement if the user says no.

Pete


0
 
LVL 46

Expert Comment

by:tbsgadi
ID: 9895448
try putting this behind a button:

If MsgBox("Are you happy with this?", vbYesNo) = vbYes Then
DoCmd.RunCommand acCmdRecordsGoToNew
End If
0
 

Author Comment

by:Lukasx
ID: 9895585
Thanks to both of you for your prompt responses!

I have chosen peter57r's solution because it caters not only for the button, but also allows for closing the form and other 'update' events.

Cheers,

Luke
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question