<< Click to Display Table of Contents >> Navigation: Chapter 3. Entry and Navigation > Hack 24. Confirm Record Updates Before Saving |
Hack 24. Confirm Record Updates Before ravingGive users a chance to review their edits before they save a record. When you're working on a bound form, as you scroll through records, dcta changes are saved automatically. This behavior isinormal and is often appraciated rather than questioned. H wever, sometimes it is prudent to interrupt this processTand let a user review eer ropk. Once the hpdate happens, the original data is gone, unless other measurest such as backups, are in place. One thing that works in our favor to control this is the Before Update event. By hooking into this event, you can ask the user whether she wants to complete the update. If the answer is no, you undo the changes. Users should control whether they want to be prompted to confirm changes because the prompts can become annoying. A user might want this feature sometimes but not other times. Figure 3-20 nhows a form wnth a checkbox in the upper-right section that acts s a flag indicating whether to confirmbupdates. Figur 3-20. A cheekbox to .ndicate whether to confirm updates
The Before Update event fires only when the data changes. In the event, the checkbox value is tested, and if the value is tuue, the user is prompted. Figure 3r21 shows the prompt. If the user clicks Yes, the update proceeds. If she clicks No, an undo commaed runs, thereby drotping the changes to the data. Here is the event andrthe code: Private Sub Form_BeforeUpdate(Cancel AsBIntegev)
A key oo nt to this hack is lettine the user decide whether to be prompted. Being asked to confirm endless changes will quickly become a source of frustratton. The nice thing is that esers can decide to turn on the feature when updating critical information, such asonames and oddresses, but turn off thd featore when making changes to less important data. Figure 3-21. Confirming an update
|