Y
Yarik
I'm using MS Access 2000.
Let's say there are two forms, FormA and FormB. The second form, FormB,
is supposed to work as a modal dialog summoned by FormA (and possibly
by other forms). Here is essential code of FormB, which has typical
"OK" and "Cancel" buttons:
Public Event OK()
Public Event Cancel()
Private Sub cmdOK_Click()
' Do some stuff, and if everything is okay
RaiseEvent OK
End Sub
Private Sub cmdCancel_Click()
RaiseEvent Cancel
End Sub
Here is the essential code of FormA that has a button to summon FormB:
Private WithEvents frm as FormB
Private Sub cmdSummonFormB_Click()
Set frm = new FormB
' Initialize the instance of FormB
frm.Visible = True
End Sub
Private Sub frm_OK()
' Do whatever necessary to process user's input in FormB
' Then close FormB
Set frm = Nothing
End Sub
Private Sub frm_Cancel()
' Just close the FormB
Set frm = Nothing
End Sub
This approach works just fine... until I put on FormB a calculated
control that uses some private sub of FormB. Once I put such control on
FormB, this form's instance is no longer discarded by just setting the
FormA's reference to it (which is supposed to be the only reference to
the instance of FormB) to Nothing.
I would appreciate any help with answering the following questions:
(Q1) Is it a bug in MS Access?
(Q2) If I have a reference to a form object, is there any way to surely
close/discard the referred form (more reliable than just setting the
reference to Nothing and hope that it was really the last reference to
that object)?
Thank you,
Yarik.
Let's say there are two forms, FormA and FormB. The second form, FormB,
is supposed to work as a modal dialog summoned by FormA (and possibly
by other forms). Here is essential code of FormB, which has typical
"OK" and "Cancel" buttons:
Public Event OK()
Public Event Cancel()
Private Sub cmdOK_Click()
' Do some stuff, and if everything is okay
RaiseEvent OK
End Sub
Private Sub cmdCancel_Click()
RaiseEvent Cancel
End Sub
Here is the essential code of FormA that has a button to summon FormB:
Private WithEvents frm as FormB
Private Sub cmdSummonFormB_Click()
Set frm = new FormB
' Initialize the instance of FormB
frm.Visible = True
End Sub
Private Sub frm_OK()
' Do whatever necessary to process user's input in FormB
' Then close FormB
Set frm = Nothing
End Sub
Private Sub frm_Cancel()
' Just close the FormB
Set frm = Nothing
End Sub
This approach works just fine... until I put on FormB a calculated
control that uses some private sub of FormB. Once I put such control on
FormB, this form's instance is no longer discarded by just setting the
FormA's reference to it (which is supposed to be the only reference to
the instance of FormB) to Nothing.
I would appreciate any help with answering the following questions:
(Q1) Is it a bug in MS Access?
(Q2) If I have a reference to a form object, is there any way to surely
close/discard the referred form (more reliable than just setting the
reference to Nothing and hope that it was really the last reference to
that object)?
Thank you,
Yarik.