Solved

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

Posted on 2003-12-08
3
310 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
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

706 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now