views:

192

answers:

2

What could be the cause of the above error when trying to use an MDB file from a VB app?

The access version of the MDB file is 6.68.

I have a feeling this might have been caused by someone trying to open the .mdb file from a newer version of Access and it may have corrupted the MDB.

How can this problem be solved?

A: 

What happens if you try to open the MDB from Access instead of from your VB app? Does Access recognize the database format?

HansUp
I don't have a copy of Access to try this.
JulesTown
A: 

Here is some VBScript which, hopefully, will get a version for you. Save this in an ordinary text file with a vbs extension and drag and drop an mdb onto it. This is a very quick sketch, and only roughly tested.

Set fs = CreateObject("Scripting.FileSystemObject")

If WScript.Arguments.Count > 0 Then
    sPath = WScript.Arguments.Item(0)
Else
    sPathTemp = Left(WScript.ScriptFullname, _
        InStrRev(WScript.ScriptFullname, "\"))

    sPath = InputBox("Enter Path and Name of .mdb", "Get Ver", sPathTemp)
End If

If sPath = "" Or fs.FileExists(sPath) = False _
    Or Right(sPath, 4) <> ".mdb" Then

    MsgBox "Not a valid file: " & vbCrLf & sPath, 64, "Get Ver" 
Else

    Set cnnDB = CreateObject("ADODB.Connection")
    cnnDB.Provider = "Microsoft.Jet.OLEDB.4.0"
    cnnDB.Mode = 1 ''adModeRead

    On Error Resume Next
    cnnDB.Open sPath

    If Err.Number <> 0 Then
         MsgBox "Error"
    Else
        MsgBox "4 = Access 97, 5 = Access 2000 (2002?)" & vbcrlf & _
        "Value for " & sPath & " is: " & _
        cnnDB.Properties.Item("Jet OLEDB:Engine Type").Value
        cnnDB.Close
    End If
End If
Remou