|
-
Jul 21st, 2005, 10:15 AM
#1
Thread Starter
New Member
VBA excel password problem
I created a typical password program with VB using adodc's that
asked the user to input a username and password when logging in etc.
This works fine in VB but i have tryed to run this in VBA for Excel
and the connection doesnt seem to work. Here is my FormLoad:
Private Sub Form_Load()
Set con = New ADODB.Connection
Dim ssql As String
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=YYYYYYYYY"
con.Open
end sub
Here is the code under my OK command button on the login form:
ssql = "select * from login where username='" & Text1.Text & "' and password='" & Text2.Text & "'"
rs.Open ssql, con, adOpenDynamic, adLockOptimistic
When i click OK after inputting my username and password I receive an
error message saying "the connection cannot be used to perform this operation.It is either closed or invalid in this context".
Everything seems to be in order except for "con"
Any suggestions or advice otherwise? It would be greatly appreciated
-
Jul 21st, 2005, 12:00 PM
#2
Re: VBA excel password problem
Did you add a reference to MS ActiveX Data Objects 2.x Object library?
Can you verify if the DSN is correctly connecting to the db?
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 
-
Jul 22nd, 2005, 03:33 AM
#3
Thread Starter
New Member
Re: VBA excel password problem
i have referenced that particular library, im not sure about the DSN though
-
Jul 22nd, 2005, 05:38 AM
#4
New Member
Re: VBA excel password problem
Have you Dim'd and Set rs?
-
Jul 25th, 2005, 03:41 AM
#5
Thread Starter
New Member
Re: VBA excel password problem
yes i have, still not working! very strange
-
Jul 25th, 2005, 11:39 AM
#6
Re: VBA excel password problem
I just noticed that your event in Excel is Form_Load. There is no event like that in Excel. If its a UserForm then it would
be UserForm_Initialize(). If its when Excel opens then its Workbook_Open()
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 
-
Jul 26th, 2005, 03:30 AM
#7
Thread Starter
New Member
Re: VBA excel password problem
yes that should be it actually, had a feeling there was something different with vba in excel, thats great, thanks very much!
-
Jul 26th, 2005, 03:33 AM
#8
Thread Starter
New Member
Re: VBA excel password problem
excellent, works perfect, thanks robdog
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
|