I need the VBA code to do the Access Compact and Repair routine.
The following code fails with Access 64-bit.
Dim objJE As Object
Set objJE = CreateObject("JRO.JetEngine")
If Not objJE Is Nothing Then
objJE.CompactDatabase _
GetDBProvider & "Data Source=" & dbFileName & ";Jet OLEDB:Database Password=" & DBPW, _
GetDBProvider & "Data Source=" & tempFile & ";Jet OLEDB:Database Password=" & DBPW
End If
Set objJE = Nothing
'GetDBProvider code is
#If Win64 Then
' 64-bit Office CANNOT use Jet. It must use ACE.
GetDBProvider = "Provider=Microsoft.ACE.OLEDB.12.0;"
#Else
' 32-bit Office defaults to legacy Jet
GetDBProvider = "Provider=Microsoft.Jet.OLEDB.4.0;"
#End If