|
-
April 18th, 2001, 07:51 AM
#1
"Operation not allowed when object is closed
I hope someone out there can help me with this. I compiled an application into an exe. The application seems to work fine. When I load the application, I connect to SQL Server then when I close the application, in the unload event of the MDI form, I make sure to disconnect my Connection. Here is my code. Again, no evident problems, the application seems to close.
If Not Cn Is Nothing Then
If (Cn.State = adStateOpen) Then
Cn.Close
Set Cn = Nothing
frmMDI.mnuFileDisconnect.Enabled = False
frmMDI.mnuFileConnect.Enabled = True
frmMDI.mnuFileMainForm.Enabled = False
frmMDI.mnuReportsStaticReport.Enabled = False
frmMDI.mnuReportsAdminReport.Enabled = False
FlagIsConnected = False
End If
End If
However when I logoff my computer. I get the run-time error 3704 "Operation is not allowed when the object is closed". In the task manager after closing my application, I noticed that it is still present. When I try to end task from the Task Manager, I will get this same error.
Please help
-
April 18th, 2001, 08:16 AM
#2
Re: "Operation not allowed when object is closed
Do you get any errors when you close your application?
Make sure to unload all the forms and close all the recordsets and set them to nothing
Iouri Boutchkine
[email protected]
-
April 18th, 2001, 08:26 AM
#3
Re: "Operation not allowed when object is closed
I get no errors when I close the application, that's what I find funny. I've looked at all individual forms and on the unload event I close all recordsets and set them to nothing. For experimentation, I just tried adding the end statement when I close the application, it seems to completely close the application but I know this is not good programming practice. Maybe in my disconnect procedure, how can I check to see if a form is loaded and if it is loaded, then unload it. I need to check for this because If I just loop through all forms and call the unload event, if I have statements that are closing recordsets in the unload event, I will get the error "Operation not allowed when object is open"
Thanks
-
April 18th, 2001, 08:51 AM
#4
Re: "Operation not allowed when object is closed
That is how you can check if the form is loaded
Public Function IsLoaded(ByVal form_name As String) As Boolean
Dim frm As Form
IsLoaded = False
For Each frm In Forms
If frm.Name = form_name Then
IsLoaded = True
Exit For
End If
Next frm
End Function
Iouri Boutchkine
[email protected]
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
|