Search code examples
ms-accessvb6ms-access-2007database-connection

VB6 & Access 2007 connection problems


OK, so I've read this identical question, but the answers don't work for me:

Connecting VB6 and MS Access 2007

I've removed the reference to Microsoft DAO 3.6 Object Library, and replaced it with a reference to Microsoft Office 12.0 Access database engine Object.

Here's my code:

Dim rcdSetData As ADODB.Recordset

Set rcdSetData = New ADODB.Recordset
rcdSetData.CursorType = adOpenStatic
rcdSetData.ActiveConnection = _
    "Provider=Microsoft.Jet.OLEDB.4.0; " _
    & "Data Source=" & DBName & "; "

I can open Access 2003 *.mdb files just fine, but when I try to open an Access 2007 *.accdb file, I get:

Error #blahblah, Unrecognized database format 'C:\path\foo.accdb'

foo.accdb is a valid Access 2007 file, as far as Access 2007 cares. No password, BTW, and it isn't open in Access when I run the program.

I'm stumped. EVERY answer I can find on the web says I'm doing this right.... :\


Solution

  • If you have recently re-installed VB6, make sure you download and install the service pack SP6 for it.