S
Steve
Hello -
I am hoping someone can enlighten me to why this either a) Access 97 bug, or
b) my ignorance, is causing the following results:
Initial Problem:
I have a subform which needs to reference the parent form in multiple
locations in multiple procedures. Originally I just used plain old
Me.Parent, which worked fine except the database after closing would hang
Access (which would never close short of rebooting or forcing it with the
Task Manager).
Initial Workaround:
Through careful elimination, I found that the Access hang only occurred
after using a procedure that had the Me.Parent reference, and further
elimination narrowed it down to those lines. I found a workaround by
creating a form object that I set to the parent form:
Dim frmParent as Form
Set frmParent = Me.Parent
My Current Issue:
This worked in that procedure, so I proceded to create a module-level
variable to store the reference once, setting it in the form's Open event:
(General Declarations)
Private mfrmParent As Form
(Form_Open)
Set mfrmParent = Me.Parent
(Form_Close)
Set mfrmParent = Nothing
Then I used the mfrmParent form variable - which should point to the
unchanging parent form from this subform's opening until closing - in every
procedure in place of Me.Parent. No hang, but now I receive an error of:
Run-time error '91':
Object variable or With block variable not set
This error occurs even if it is the first statement in the procedure like
this:
Debug.Print mfrmParent.Name
That same statement would work in the Form_Open event, but everywhere else I
receive this error. Considering that I am using a module scope variable, how
is it losing its reference? There are no other Sets of that variable
anywhere (I even removed the Form_Close procedure's Set mfrmParent = Nothing
to be sure), and the form & subform never even lose focus. Any help
understanding this situation would be much appreciated!
Thanks!
Steve
I am hoping someone can enlighten me to why this either a) Access 97 bug, or
b) my ignorance, is causing the following results:
Initial Problem:
I have a subform which needs to reference the parent form in multiple
locations in multiple procedures. Originally I just used plain old
Me.Parent, which worked fine except the database after closing would hang
Access (which would never close short of rebooting or forcing it with the
Task Manager).
Initial Workaround:
Through careful elimination, I found that the Access hang only occurred
after using a procedure that had the Me.Parent reference, and further
elimination narrowed it down to those lines. I found a workaround by
creating a form object that I set to the parent form:
Dim frmParent as Form
Set frmParent = Me.Parent
My Current Issue:
This worked in that procedure, so I proceded to create a module-level
variable to store the reference once, setting it in the form's Open event:
(General Declarations)
Private mfrmParent As Form
(Form_Open)
Set mfrmParent = Me.Parent
(Form_Close)
Set mfrmParent = Nothing
Then I used the mfrmParent form variable - which should point to the
unchanging parent form from this subform's opening until closing - in every
procedure in place of Me.Parent. No hang, but now I receive an error of:
Run-time error '91':
Object variable or With block variable not set
This error occurs even if it is the first statement in the procedure like
this:
Debug.Print mfrmParent.Name
That same statement would work in the Form_Open event, but everywhere else I
receive this error. Considering that I am using a module scope variable, how
is it losing its reference? There are no other Sets of that variable
anywhere (I even removed the Form_Close procedure's Set mfrmParent = Nothing
to be sure), and the form & subform never even lose focus. Any help
understanding this situation would be much appreciated!
Thanks!
Steve