New JRO.JetEngine Throwing Class Not Registered (1 Viewer)


Registered User.
Local time
Today, 08:09
Feb 3, 2002
I thought as I haven't updated my Access skills for some time and am probably rusty around the edges I should buy a more up to date book and work through it. At worst I will cover what I already use daily but maybe as I am not a complete begineer I may pick up more this time around...

The book I choose was Access 2016 Programming By Example. in chapter 10 there is the following module.

Sub mySetPass_AndOpenDB_withADO()
On Error GoTo ErrorHandler
Dim jetEng As JRO.JetEngine
Dim conn As ADODB.Connection
Dim strCompactFrom As String
Dim strCompactTo As String
Dim strPath As String

    strPath = CurrentProject.Path & "\"
    strCompactFrom = "Northwind.mdb"
    strCompactTo = "Northwind_P.mdb"
    Set jetEng = New JRO.JetEngine
    ' Compact the database specifying
    ' the new database password
        jetEng.CompactDatabase "Data Source=" & _
        strPath & strCompactFrom & ";", _
        "Data Source=" & strPath & strCompactTo & ";" & _
        "Jet OLEDBatabase Password=welcome"
    MsgBox "Ther database " & strPath & strCompactTo & " is password protected"
    Set jetEng = Nothing
    'Open password file
    Set conn = New ADODB.Connection
    With conn
        .Provider = "Microsoft.Jet.OLEDB.4.0;"
        .ConnectionString = "Data Source =" & strPath & strCompactTo & "; JetOLEDB:Database Password = welcome"
    End With
    If conn.State = adStateOpen Then
        MsgBox "PW db opened"
    End If
        MsgBox "DB Closed"
    Set conn = Nothing
Exit Sub

    If Err.Number = -2147217897 Then
        Kill strPath & strCompactTo
    ElseIf Err.Number = -2147467259 Then
        MsgBox "Close db before compacting"
        Exit Sub
        MsgBox Err.Number & ": " & Err.Description
        Exit Sub
    End If

End Sub

This code fails consistently on Set jetEng = New JRO.JetEngine with error -2147221164 Class not registered.

I thought this was likely a reference issue. I thought perhaps the dll is not in my system. It was in my system. I thought it may not be registered, I registered it.

I thought perhaps I need to unregister it, I cleared the reference from Access, closed Access, opened command prompt as administrator unregistered the dll and then registered it, reopened access, referenced the dll again and still getting this error.

I really cant see what else it can be. Anyone got an idea?


Lifelong Learner
Local time
Today, 00:09
Mar 14, 2017
Do a search for msjro.dll on your hard drive.
Check the references in your applications for 'Microsoft Jet and Replication Objects 2.6 Library', under the References portion of VBA project options.

(I plagiarized this from

If you're rusty, that's an interesting place to begin brushing!


Registered User.
Local time
Today, 08:09
Feb 3, 2002
None of those are helping and I have already checked all them.

The book came with code. The error is in their version of the code too. I am wondering if its a 64 bit issue?


Local time
Today, 08:09
Jan 14, 2017
Are there any APIs with that code? Are you able to test it in 32-bit Access?

Here's some alternative code using DAO to alter a database password externally. USE WITH CAUTION!

Public Function AlterDBPassword() As Boolean

On Error GoTo Err_Handler

    Dim db As DAO.Database, strPath As String, strOldPwd As String, strNewPwd As String
    strPath = "Enter full path here"
    strOldPwd = "OldPasswordHere" ' leave blank if no password
    strNewPwd = "NewPasswordHere"
    Set db = DBEngine.OpenDatabase(strPath, True, False, "MS Access;PWD=" & strOldPwd)
    db.NewPassword strOldPwd, strNewPwd
   ' Set db = DBEngine.OpenDatabase(strPath, True, False, "MS Access;PWD=LetMeIn") 'specified db has a password LetMeIn
   ' db.NewPassword "LetMeIn", "Isladogs" 'change Pwd to isladogs

    Set db = Nothing
    Exit Function
    MsgBox "Error " & Err & " in AlterDBPassword procedure: " & vbCrLf & Err.Description
    GoTo Exit_Handler

End Function

If it helps I also have DAO code to compact an external database
Last edited:

Users who are viewing this thread

Top Bottom