|
-
Jan 29th, 2003, 01:57 AM
#1
Thread Starter
Addicted Member
Query Unload
Hi all,
I have the following code in the QueryUnload procedure of a form:
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If UnloadMode = vbFormControlMenu then
CleanUp 'procedure to unload all forms & clean up db connections
Unload Me
Set Form1 = Nothing
End If
End Sub
In CleanUp the code is:
Public Sub CleanUp()
Dim FormX As Form
For Each FormX In Forms
Unload FormX
Set FormX = Nothing
Next FormX
'additional code to clean up the db connections
End Sub
My question is, are the last 2 lines in the Query Unload procdure ie.
Unload Me
Set Form1 = nothing
neccessary since the CleanUp procedure unloads all forms and set them to nothing ?
I read somewhere that it was and just wanted to confirm if it was true.
Cheers
Jack
-
Jan 29th, 2003, 04:06 AM
#2
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Jan 29th, 2003, 04:21 AM
#3
The "Unload Me" part is redundant, because you are already in the QueryUnload event. The form is already being unloaded.
The "Set Form1 = Nothing" part is only necessary if you want the Terminate event to be triggered. Next to triggering the Terminate event, it cleans up the implicitly declared Form1 variable. If you don't do it, VB will do it for you, but many people do not rely on VB to do it correctly, so you can leave it in if you like.
-
Jan 29th, 2003, 06:10 AM
#4
Thread Starter
Addicted Member
Many thanks for your responses. It has cleared this issue up for me.
Jack
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|