×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Runtime Error 462

Runtime Error 462

Runtime Error 462

(OP)
I am doing screen scraping from Reflections and have typically sent the output to Excel and never had a problem. I am now trying to write to Access. Like many of the other threads, I am getting a runtime error 462 every other time I run this code. In trying to solve the problem, I have commented out all code pertaining to recordsets and basically have left the macro as opening and closing and I still get the error. I must be missing something and not closing all references to Access.

Can anyone see something I am missing? Thank you.

CODE --> vba

Sub UpdateTest()

Dim rs As DAO.Recordset
Dim db As DAO.Database
Dim ws As DAO.Workspace

    
    dbPath = "S:\Pharmacy General\Databases Automation\Databases\Test\Test.accdb"
    Set ws = DBEngine.Workspaces(0)
    Set db = ws.OpenDatabase(dbPath)
    Set rs = db.OpenRecordset("tblRPHITemp", dbOpenDynaset)
    
    ....processing code

    rs.Close
    Set rs = Nothing
    db.Close
    Set db = Nothing
    ws.Close
    Set ws = Nothing
    Access.Application.Quit


End Sub 

You don't know what you don't know...

RE: Runtime Error 462

(OP)
After some additional reading, I think I have it fixed without really understading how I fixed it. I changed my code to:

CODE --> vba

Sub UpdateTest()

Dim objAccess as Access.Application
Dim rs As DAO.Recordset
Dim db As DAO.Database
    
    dbPath = "S:\Pharmacy General\Databases Automation\Databases\Test\Test.accdb"
    Set db = objAccess.DBEngine.OpenDatabase(dbPath)
    Set rs = db.OpenRecordset("tblRPHITemp", dbOpenDynaset)
    
    ....processing code

    objAccess.Quit acQuitSaveAll    
    Set objAccess = Nothing
    Set rs = Nothing
    Set db = Nothing

End Sub 

You don't know what you don't know...

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close