Dim strUserName As String, strPassword As String
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Private Sub cmdlogin_Click()
OpenCon
rs.Open "SELECT * FROM [tbladmin] WHERE [username]= '" & txtUsername.Text & "'", con, adOpenStatic, adLockOptimistic
If rs.RecordCount <> 0 Then
If rs![Password] = txtPassword.Text Then
If rs![user_type] = "Principal" Then
MsgBox "The Principal has login", vbOKOnly + vbInformation, "LOGIN"
frmMain.Transaction.Visible = True
frmMain.Maintenance.Visible = True
frmMain.Reports.Visible = True
frmMain.Exit.Visible = True
frmMain.Others.Visible = True
frmMain.Files.Visible = True
Login1 = 1
'frmMain.Text3 = Text1.Text
'frmMain.Text4 = TimeValue(Now)
End If
End If
End If
End Sub
run time error 3709
Page 1 of 18 Replies - 1620 Views - Last Post: 21 September 2012 - 07:19 AM
#1
run time error 3709
Posted 20 August 2012 - 06:18 AM
please help me I'm having error in rs.Open "SELECT * FROM [tbladmin] WHERE [username]= '" & txtUsername.Text & "'", con, adOpenStatic, adLockOptimistic I think my code is right I dunno where I went wrong.
Replies To: run time error 3709
#2
Re: run time error 3709
Posted 21 August 2012 - 12:42 PM
the error says all. either you dont open your connection or the string for the connection is invalid. if you could show us the code where you open the connection we may give you better help
#3
Re: run time error 3709
Posted 25 August 2012 - 06:53 PM
raziel_, on 21 August 2012 - 12:42 PM, said:
the error says all. either you dont open your connection or the string for the connection is invalid. if you could show us the code where you open the connection we may give you better help
Public con As New ADODB.Connection
Public Sub OpenCon()
Set con = New ADODB.Connection
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = " & App.Path & "\database\enrollment.mdb"
End Sub
#4
Re: run time error 3709
Posted 26 August 2012 - 02:10 AM
Try checking if the connection is actually opened (think it's the State property).
#5
Re: run time error 3709
Posted 31 August 2012 - 04:21 PM
This is a theory, not for sure. Try removing the "New" from your "As New" in your line 1. If it solves your problem, I'll tell you why I think so. In any case, it shouldn't be there, so remove it.
#6
Re: run time error 3709
Posted 17 September 2012 - 08:06 PM
the code should be like this to run normally
Dim strUserName As String, strPassword As String
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Public Sub OpenCon()
if con.state = 0 then
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = " & App.Path & "\database\enrollment.mdb"
end if
End Sub
Private Sub cmdlogin_Click()
OpenCon
rs.Open "SELECT * FROM [tbladmin] WHERE [username]= '" & txtUsername.Text & "'", con, adOpenStatic, adLockOptimistic
If rs.RecordCount <> 0 Then
If rs![Password] = txtPassword.Text Then
If rs![user_type] = "Principal" Then
MsgBox "The Principal has login", vbOKOnly + vbInformation, "LOGIN"
frmMain.Transaction.Visible = True
frmMain.Maintenance.Visible = True
frmMain.Reports.Visible = True
frmMain.Exit.Visible = True
frmMain.Others.Visible = True
frmMain.Files.Visible = True
Login1 = 1
'frmMain.Text3 = Text1.Text
'frmMain.Text4 = TimeValue(Now)
End If
End If
End If
End Sub
#7
Re: run time error 3709
Posted 20 September 2012 - 03:08 PM
leixnt, how is your code different from the OP's?
#8
Re: run time error 3709
Posted 20 September 2012 - 06:36 PM
Try This.
Dim strUserName As String, strPassword As String
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Public Sub OpenCon()
Set con=new ADODB.Connection
if con.state = 0 then
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = " & App.Path & "\database\enrollment.mdb"
end if
End Sub
Private Sub cmdlogin_Click()
Set rs=new ADODB.Recordset
OpenCon
rs.Open "SELECT * FROM [tbladmin] WHERE [username]= '" & txtUsername.Text & "'", con, adOpenStatic, adLockOptimistic
If rs.RecordCount <> 0 Then
If rs![Password] = txtPassword.Text Then
If rs![user_type] = "Principal" Then
MsgBox "The Principal has login", vbOKOnly + vbInformation, "LOGIN"
frmMain.Transaction.Visible = True
frmMain.Maintenance.Visible = True
frmMain.Reports.Visible = True
frmMain.Exit.Visible = True
frmMain.Others.Visible = True
frmMain.Files.Visible = True
Login1 = 1
'frmMain.Text3 = Text1.Text
'frmMain.Text4 = TimeValue(Now)
End If
End If
End If
End Sub
#9
Re: run time error 3709
Posted 21 September 2012 - 07:19 AM
In other words, do as I suggested, or just copy Bert's code since he was kind enough to do it for you.
If that doesn't work, we'll look at something else.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|