Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run time error 91

Status
Not open for further replies.

wonghei7

Technical User
Jun 7, 2003
9
SG
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?
 
Just as you create a new instance of the connection object (Set cn = New ADODB.Connection) before you can use it, you must create a new instance of the Recordset object before you can use it.


Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Thanks so much, CajunCenturion, you're a life saver. Got it to work.
 
Glad it helped.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top