this is my code for the login form using ms access would someone please help me? Everytime I run the program, it usually says connection cannot be used. If I would debug the program it will highlight "rspassword.Open "Select * from table1"
I also used a module here
Public rs As New ADODB.Recordset
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
Dim con As New ADODB.Command
Dim rs As New ADODB.Recordset
Private Sub cmdcancel_Click()
Unload Me
End Sub
Private Sub cmdLogin_Click()
Set rspassword = New ADODB.Recordset
rspassword.Open "Select * from table1"
If rspassword.RecordCount > 0 Then
Do Until rspassword.EOF
If txtUsername.Text = rspassword!UserName And txtPassword.Text = rspassword!Password Then
'frmmain.L1.Caption = Text1.Text
Set rspassword = Nothing
Unload Me
frmmain.Show
ctr = 0
Exit Do
Else
rspassword.MoveNext
ctr = ctr + 1
End If
Loop
If ctr > 0 Then
Set rspassword = Nothing
MsgBox "Invalid!", vbExclamation
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
ctr = 0
End If
End If
End Sub