-
Jun 17th, 2007, 03:36 PM
#1
Thread Starter
Lively Member
[RESOLVED] Is there a cn.open = true command?
Hello again. Ok, everthing is coming along well, but if I run my program and close it before I make a connection, I get a Object Variable or With block variable not set. I tried to use:
VB Code:
Private Sub Form_Unload(Cancel As Integer)
If CN.Open > 0 Then
CN.Close
Set CN = Nothing
End If
End Sub
'and
Private Sub Form_Unload(Cancel As Integer)
If CN.Open = True Then
CN.Close
Set CN = Nothing
End If
End Sub
'and
Private Sub Form_Unload(Cancel As Integer)
If Len(CN.Open) > 0 Then
CN.Close
Set CN = Nothing
End If
End Sub
to see if the connection string was open, and close it if it was and if not then exit the program without trying to close something that is not open. They all error, if there is no connection. I need to find a way to make the program not error when user(me) clicks the trapclose without connecting first. It works fine if I establish a connection first. If you need me to, I can post the code I have so far. But it is getting a bit lengthy at this point so if you know what I am refering to, then I won't have to use unneccessary space. Thanks again. I will get through this eventually. I am just learning here...
-
Jun 17th, 2007, 03:47 PM
#2
Re: Is there a cn.open = true command?
Just check the state of the connection object.
Code:
If TypeName(cn) <> "Nothing" Then
If cn.State = adStateOpen Then
cn.Close
End If
Set cn = Nothing
End If
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
-
Jun 17th, 2007, 03:50 PM
#3
Thread Starter
Lively Member
Re: Is there a cn.open = true command?
Thanks!! That works perfectly... I apologize for the frequency of my posts, but as I said above I am learning as I write this app. When I am done I will definatly share it, I think you guys will like it.
-
Jun 17th, 2007, 03:52 PM
#4
Re: Is there a cn.open = true command?
We dont mind at all if you post a bunch As long as you dont post duplicates or spam then its all good.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
-
Jun 17th, 2007, 04:28 PM
#5
Thread Starter
Lively Member
Re: Is there a cn.open = true command?
Ok I will mark this one a resolved, when I get to another block I will start another thread. I think thats how I am supposed to do it. If not let me know. All my posts thus far have been for different problems I have run into.
-
Jun 17th, 2007, 04:51 PM
#6
Re: [RESOLVED] Is there a cn.open = true command?
Yes, each thread should be on a single issue/problem/topic.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
-
Jun 17th, 2007, 05:05 PM
#7
Thread Starter
Lively Member
Re: [RESOLVED] Is there a cn.open = true command?
I just want to say thanks for the time you guys take out of your busy schedules to answer these posts. I wouldn't be where I am at on this program and my vb knowledge right now if it wasn't for you guys helping me out. So, thanks!
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
|