L
.Len B
THE SETUP. (Access 2003)
I have a with several command buttons and a subform.
The subform has several textboxes and a combo box.
The (sub)Form_BeforeUpdate(Cancel As Integer) contains code
to validate the detail record. It handles
* required things
* warnings
* MsgBox accordingly
THE PROBLEM.
In addition to using the provided 'Save' button, users are able to
save incomplete/inappropriate detail records by exiting to the main
form (say by clicking cmdPrint or cmdClose). The BeforeUpdate code
doesn't fire and the record isn't validated and the user isn't warned.
I have found this which, although not exactly on topic, appears that
it might apply to this situation:-
When you close a form containing a subform, the subform
and its records are unloaded after the form. The Deactivate
event doesn't occur for subforms, so closing a main form
triggers a Deactivate event only for the main form. The
events for the controls, form, and subform occur in the
following order:
Events for the subform's controls(eg Exit & LostFocus)
Events for the form's control (incl the subform control itself)
Events for the form (eg Deactivate & Close)
Events for the subform
Am I correct saying that the subform BeforeUpdate does not fire in the
circumstances described?
Or is there a setting that controls this?
Or is there a way I can force a BeforeUpdate event?
Or is there a different event I can use?
As I cannot know which subform control might be active when the user
clicks outside the subform, I cannot invoke the code in an Exit event.
In any case, doing so would surely raise inappropriate MsgBox popups.
The form itself has no exit event and no other event seems applicable.
I have a with several command buttons and a subform.
The subform has several textboxes and a combo box.
The (sub)Form_BeforeUpdate(Cancel As Integer) contains code
to validate the detail record. It handles
* required things
* warnings
* MsgBox accordingly
THE PROBLEM.
In addition to using the provided 'Save' button, users are able to
save incomplete/inappropriate detail records by exiting to the main
form (say by clicking cmdPrint or cmdClose). The BeforeUpdate code
doesn't fire and the record isn't validated and the user isn't warned.
I have found this which, although not exactly on topic, appears that
it might apply to this situation:-
When you close a form containing a subform, the subform
and its records are unloaded after the form. The Deactivate
event doesn't occur for subforms, so closing a main form
triggers a Deactivate event only for the main form. The
events for the controls, form, and subform occur in the
following order:
Events for the subform's controls(eg Exit & LostFocus)
Events for the form's control (incl the subform control itself)
Events for the form (eg Deactivate & Close)
Events for the subform
Am I correct saying that the subform BeforeUpdate does not fire in the
circumstances described?
Or is there a setting that controls this?
Or is there a way I can force a BeforeUpdate event?
Or is there a different event I can use?
As I cannot know which subform control might be active when the user
clicks outside the subform, I cannot invoke the code in an Exit event.
In any case, doing so would surely raise inappropriate MsgBox popups.
The form itself has no exit event and no other event seems applicable.