By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,849 Members | 2,361 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,849 IT Pros & Developers. It's quick & easy.

Force user to select Save cmd

P: 3
Have read several posts and it appears that forcing a user to use the "Save" cmd is not used. However, I have a situation with a main form that has three pages/tabs. Each page has a subform1 and a subform2 inside of the subform1, (subform2 is three deep basically). If a user navigates away to a different page or attempts to close the form, I want them to be warned they will lose all changes. OR they can select Save to exit the page gracefully. Any assistance would be greatly appreciated.

Thank you.

Blondie
Nov 3 '08 #1
Share this Question
Share on Google+
1 Reply


missinglinq
Expert 2.5K+
P: 3,532
In point of fact, unless you've explicitly done something to make this happen, it won't. Moving from one subform to another or from subform to main form will not result in the record on the form being lost, but rather it will be saved by default.

If you want to force the user to explicitly save the record, you don't really need a "Save" button, you need to place code in each form's BeforeUpdate event that asks them if they want to save it or not:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_BeforeUpdate(Cancel As Integer)
  2.  If MsgBox("Would You Like To Save The Changes To This Record?", vbQuestion + vbYesNo + vbDefaultButton1, "Save Changes to Record ???") = vbNo Then
  3.   Me.Undo
  4.  End If
  5. End Sub
Welcome to Bytes!

Linq ;0)>
Nov 3 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.