How do you block right-clicking and select form close in the form header, unless you have completely disabled right-clicking or shortcut menus?
Or Alt-f4
I can't believe all of these are blocked in 3 minutes of code.
(Just being argumentative hear by the way)
Oh - I don't block any of those things.
2 lines of code as posted earlier.
1) global blAllowSave as boolean
2) [in the form's BeforeUpdate event]--if blAllowSave=False then Cancel=true
(and of course my Save button sets blAllowSave to True)
...done deal. Now you can nurture this incredibly simple and intuitive expectation to the user: "Nothing ever gets saved unless you press the button"........which is pretty much what they came into the picture expecting, anyway, given the presence of a button labeled "save".
I'd say that's probably more like 60 seconds or less of coding. And now you can skip all of those ugly scenarios like:
- the user dirties the record, then wants to close the form, assuming it won't save
- then you have to catch that error "you can't close this object", undo the dirty, probably add in some confirmation to figure out what the user actually
does want to do, etc. etc. All of that junk is just gone, they're not even scenarios any more.
- the user inadvertently dirties a record then wants to change a tab page
Of course there are a thousands ways to get around all of these scenarios. I just cancel them all out by Cancel=True if my special button boolean flag isn't True.