riktek
Member
- Local time
- Today, 03:09
- Joined
- Dec 15, 2023
- Messages
- 102
I've been doing this long enough to both understand the topic and recognize that the understanding I glean often isn't at all what is occurring, notwithstanding a preternaturally rigorous review of the documentation and online commentary.
So it is here, where I'm encountering what seems to me to be anomalous behavior (or what I have come to describe in a fit of self-justification as resistance to configuration).
I'm fiddling with some code in a startup / display form and attempted without success to cancel the Open event. The purpose of this is irrelevant to the question but for the curious, it's simply part of handing processing off to another module. The extent of the startup form's module is:
My understanding, not least because of the estimable words [the link to which I'm apparently not permitted to post] of @The_Doc_Man :
Alas, this does not occur (in Access 2007, to be sure, but still). Imagine one's dismay at then seeing in the Immediate pane:
Apparently, ALL of the other events occur (frmStartup's Load and Close, that is), at least the way I'm doing it. The expected behavior, and with some justification (as noted), is that event progression should immediately cease such that no other form events, including Load and Close, would occur. So, canceling Open would prevent Load (not to mention Activate, Current, Deactivate, Unload, and Close); canceling BeforeUpdate would prevent AfterUpdate; etc.
The question is, provided my implementation isn't flawed (always a risk), if event progression does not cease immediately, or at the end of a canceled event procedure, then what happens instead and can event progression otherwise be terminated?
I'm missing something, clearly.
So it is here, where I'm encountering what seems to me to be anomalous behavior (or what I have come to describe in a fit of self-justification as resistance to configuration).
I'm fiddling with some code in a startup / display form and attempted without success to cancel the Open event. The purpose of this is irrelevant to the question but for the curious, it's simply part of handing processing off to another module. The extent of the startup form's module is:
Code:
Option Compare Database
Option Explicit
Private Sub Form_Close()
Debug.Print Me.Name & vbTab & "Form_Close()"
End Sub
Private Sub Form_Load()
Debug.Print Me.Name & vbTab & "Form_Load()"
End Sub
Private Sub Form_Open(Cancel As Integer)
Debug.Print Me.Name & vbTab & "Form_Open()"
Cancel = True 'Behavior is identical whether before or after this With block:
With Startup 'Startup is a predeclared class module.
If Not .Main Then .SetMain
End With
End Sub
My understanding, not least because of the estimable words [the link to which I'm apparently not permitted to post] of @The_Doc_Man :
If you cancel the Form_Open event by returning -1 or TRUE to the Cancel parameter, then none of the other events occurs because the form does not open. It immediately gets dereferenced by the GUI.
Alas, this does not occur (in Access 2007, to be sure, but still). Imagine one's dismay at then seeing in the Immediate pane:
Code:
frmStartup Form_Open()
Startup Class_Initialize()
frmStartup Form_Load()
frmStartup Form_Close()
frmMain Form_Open()
frmMain Form_Load()
Apparently, ALL of the other events occur (frmStartup's Load and Close, that is), at least the way I'm doing it. The expected behavior, and with some justification (as noted), is that event progression should immediately cease such that no other form events, including Load and Close, would occur. So, canceling Open would prevent Load (not to mention Activate, Current, Deactivate, Unload, and Close); canceling BeforeUpdate would prevent AfterUpdate; etc.
The question is, provided my implementation isn't flawed (always a risk), if event progression does not cease immediately, or at the end of a canceled event procedure, then what happens instead and can event progression otherwise be terminated?
I'm missing something, clearly.
Last edited: