Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Runtime error 13, while trying to open recordset in access97 DB

Posted on 2003-03-08
15
Medium Priority
?
208 Views
Last Modified: 2011-10-03
I have a Login system on the client side part of a chat program. I have tested and had success with this very same login system on a seperate program.

Private Sub Login_Click()
    Dim db As Database
    Dim rs As Recordset
   
    Set db = OpenDatabase(App.Path & "\siteusers.mdb")
    Set rs = db.OpenRecordset("users")
   
    Do While Not rs.EOF
        If rs.Fields("username") = (txtLogin.Text) And _
        rs.Fields("password") = (txtPassword.Text) Then
       
        Frame2.Visible = False
        Frame1.Visible = False
        txtName.Text = txtLogin.Text
       
        Exit Sub
    Else
        rs.MoveNext
        End If
    Loop
    txtPassword.Text = ""
    MsgBox "Incorrect Password!", vbCritical
End Sub

when i run the program and click Login i recieve the runtime error 13, at:
    Set rs = db.OpenRecordset("users")

any ideas on how to fix this? i am still a novice user of vb, so please explain :)
0
Comment
Question by:jwduke3d
  • 9
  • 3
  • 2
  • +1
15 Comments
 
LVL 2

Expert Comment

by:spauljoseph
ID: 8094222
Place the Database initializing code in the Form_Load() Event of your form. And Globally declare the db and rs variables. (Globally means, place declarations of these variables in the top most first line of your code window)

Now, open the database and recordset in the form_load event and in the Login_Click event just place the code as below:


rs.MoveFirst

Do while rs.EOF<>True
    'Your Code Here
Loop


I hope it can now run.
0
 

Author Comment

by:jwduke3d
ID: 8094272
spauljoseph, when i do it as you have said i get a runtime error 91 on rs.MoveFirst ...
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8094411
is your db/table empty?
if so, there is no first record.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:jwduke3d
ID: 8094889
no, it has 70+ users in it
0
 
LVL 1

Accepted Solution

by:
vbaRookie earned 225 total points
ID: 8096352
what references do you have set?
0
 

Author Comment

by:jwduke3d
ID: 8097425
vb for applications
vb runtime objects and procedures
vb objects and procedures
OLE automation
M$ Data Enviroment Instance 1.0
M$ DAO 3.51 Object Library
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8097750
try this little modification:
Private Sub Login_Click()
   Dim db As Database
   Dim rs As Recordset
   
   Set db = dbengine.workspaces(0).OpenDatabase(App.Path & "\siteusers.mdb",false,false)
   Set rs = db.OpenRecordset("users")

and i think you don't need a Do..Loop, just use .findfirst method to locate desired record.
   
   
0
 

Author Comment

by:jwduke3d
ID: 8098090
I still get the  runtime error 13 on  Set rs = db.OpenRecordset("users")
0
 

Author Comment

by:jwduke3d
ID: 8098121
I still get the  runtime error 13 on  Set rs = db.OpenRecordset("users")
0
 
LVL 1

Expert Comment

by:vbaRookie
ID: 8098202
would this help, not sure?

dim rs as dao.recordset
set rs=new dao.recordset

the rest of the code should work fine then
0
 

Author Comment

by:jwduke3d
ID: 8098759
no success with that :(
0
 

Author Comment

by:jwduke3d
ID: 8099325
I have fix my own problem at this point :) their was a conflict with the refrences i had, now i am up and running thats so much for all the help you guys tried to give me
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8102237
I think what vbRookie saids has to be with your problem.
0
 

Author Comment

by:jwduke3d
ID: 8107058
I agree :)
0
 

Author Comment

by:jwduke3d
ID: 8107062
good thinking, made me think.. and it did the trick!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question