How to Detect Encoded Status of an Older Access Database Part II

Bilbo_Baggins_Esq

Registered User.
Local time
Today, 14:02
Joined
Jul 5, 2007
Messages
586
Hi All,

I tried this topic in an original thread, but I posted some bum code and the thread got side tracked.
In the meantime, having not received any replies toward the purpose of the thread, I have worked toward success on this and several other goals of the add-in.

So, now I have a completed Excel Add-in that will successfully open various Access databases and gather, or deduce, certain attributes.

Many thanks to those who helped in other threads!

However, this encoding challenge still vexes me.

Yes, I have build some code which indirectly achieves the goal, but it is potentially problematic in some scenarios.
It will always run, but if the databases are large or have some startup or
close events it can really bog down the user's time involved.

I tried to see if it was a property available through “.CurrentDb.Properties.name” and no joy.

So, what I have done is to attempt a conversion of all files that are in an older format and which are not password locked.
So far, the only error that fires is is the file is encoded so I can correctly apply the attribute in my report.
Here is the code
Code:
Private Sub CheckEncoding()
'would love to find a way to directly check this attribute, however
'as of this writing, the only successful way I've been able use is to attempt conversion
'If successful the file cannot possibly be encoded
'if unsuccessful, I check the error number to see if it was fired because of existing encoding
On Error GoTo CheckEncoding_Err:

Set AccessObj = CreateObject("Access.Application") 'creates an access object within Excel VBA process

'performs the actual conversion
'if an error happens, I handle that in the On Error event
With AccessObj
    .Visible = False
    .Application.ConvertAccessProject AccessPathIn, AccessPathOut, 12
    .Application.DoCmd.Quit
End With

Kill AccessPathOut 'If I get this far, it must have successfully created a converted file, so now I need to delete it
EncodingStatus = False 'and set the status

Exit Sub

CheckEncoding_Err:
'If the conversion fails, I have to check the error number
If Err.Number = 32544 Then 'this is the error number for the valid encoding error
    EncodingStatus = True 'so we set the status to true
    Else
    'There are no known errors to encounter this piece, but it is here in case, as a fail safe
    MsgBox "Undefined error encountered in 'CheckEncoding'" & vbCrLf & _
    Err.Number & " " & Err.Description
End If

Set AccessObj = Nothing 'being finished with this sub, I have to close this object because it does not play nicely with later testing.

End Sub

So, like I said, the above code does work and does achieve the goal, but poses some time challenges and is not the way I'd like to achieve it.

Things I’ve discovered:
In Access 2010, you actually can encode/decode earlier formatted databases.
The feature is only enabled/visible when you open an earlier version database.
File>Users and Permissions>Encode/Decode Database…

I've done some additional research and it appears the Encoded feature was part of Jet and further did some digging in the libraries.

The "Jet Expression Service Type Library" (msjtes40.dll) includes:
IJetESFormula.Decode

At the bottom of the object browser it shows:
Sub Decode(lcid As <Unsupported variant type>, pbstrDecodedExpr As String, fLocalized As Long)
Member of JetES.IJetESFormula

But there is no help available and I've not been able to find anything related to this on the internet

I’m not even sure I’m searching for the right thing in the object browser.
Yes, the feature is called Encode/Decode, but in reality it is an earlier version of (ineffective) encryption.
However, I’ve not been able to find much help on encryption either.
I found DB_Encrypt which is a member of the Old Constants, but again, “No help available”.

So, I thought I’d take one last crack at this here for help.
Something tells me this can be done.
I Access can offer it as a feature, and Access can detect the encoded condition if you try to upgrade an older format file I have a hard time believing it can’t be coded in some way that is better than what I already have.

PLEASE HELP SOLVE THIS PUZZLE!
 

Users who are viewing this thread

Back
Top Bottom