Hi. I'm trying to create a user login screen by verifying the user ids and passwords maintained in a database connected via ADO. But when I run the program, the run time error 91 pops up. I still couldn't figure out what's wrong. My codes are below:
Option Explicit
Private Sub Command1_Click()
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strCnn As String
Dim exist As Boolean
Set cn = New ADODB.Connection
txtUsername.Text = Replace(txtUsername.Text, " ", ""
txtUsername.Text = LCase(txtUsername.Text)
With cn
.Provider = "Microsoft.jet.oledb.4.0"
.CursorLocation = adUseClient
.ConnectionString = App.Path + "\Quotation DB.mdb"
.Open
End With
exist = True
rs.Open "Select [UserID]from Users where ([UserID]='" & txtUsername.Text & "'), cn, adOpenKeyset"
If rs.RecordCount = 0 Then
exist = False
End If
The rs.Open line gets highlighted.
Could anyone help?
Option Explicit
Private Sub Command1_Click()
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strCnn As String
Dim exist As Boolean
Set cn = New ADODB.Connection
txtUsername.Text = Replace(txtUsername.Text, " ", ""
txtUsername.Text = LCase(txtUsername.Text)
With cn
.Provider = "Microsoft.jet.oledb.4.0"
.CursorLocation = adUseClient
.ConnectionString = App.Path + "\Quotation DB.mdb"
.Open
End With
exist = True
rs.Open "Select [UserID]from Users where ([UserID]='" & txtUsername.Text & "'), cn, adOpenKeyset"
If rs.RecordCount = 0 Then
exist = False
End If
The rs.Open line gets highlighted.
Could anyone help?