Unanswered: hiding subform with btn on subform AND by clicking away from subform?
-on current event:
-hide all subforms
-on click of a leaf node in my treeview
-make subform visible
----on save button click event:
----commit subform's record
----set focus to sub's parent
----call sub's parent's on current event to rehide the subform & recalc the tree
This works great, but it has a big problem:
If the user DOESN'T click my save button inside the subform, but rather just clicks on any random control on the main form, the subform's record DOES get committed, BUT the main form's current event never fires and thus never gets the opportunity to recalc the tree & re-hide the subforms.
I experimented with using the subform's exit event to call the main form's on current event. This DID work for the case where the user was freely clicking on any given main form control, BUT it goes into a twisted event Escher-land when clicking the subform's save button; that subform save button, in its ATTEMPT to set focus to parent (thus unfocusing itself), triggers the exit event, which attempts to hide the subform, which fails because the subform's save button still has focus...
Is there a way to handle both cases? User clicks subform's save button OR clicks away from the subform?
Added an invisible unbound checkbox "chkBusy" to the subform.
Set it to true on the subform's dirty event.
Clear it if the subform's save or cancel buttons are clicked.
On the main form, in the subform object's exit event, check the status of chkBusy, and Cancel the exit event, with a msgbox prompting the user to save or cancel before doing anything outside of the subform. This forces the user to use my save/cancel buttons within the subform itself.