dynamictiger
Registered User.
- Local time
- Today, 23:49
- Joined
- Feb 3, 2002
- Messages
- 270
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.
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?
The book I choose was Access 2016 Programming By Example. in chapter 10 there is the following module.
Code:
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"
.Open
End With
If conn.State = adStateOpen Then
MsgBox "PW db opened"
End If
conn.Close
MsgBox "DB Closed"
Set conn = Nothing
Exit Sub
ErrorHandler:
If Err.Number = -2147217897 Then
Kill strPath & strCompactTo
ElseIf Err.Number = -2147467259 Then
MsgBox "Close db before compacting"
Exit Sub
Else
MsgBox Err.Number & ": " & Err.Description
Exit Sub
End If
Resume
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?