2

Is there a way to programmatically convert an Access 2010 ACCDB file to an Access 95/97 MDB file?

CJ7
  • 22,579
  • 65
  • 193
  • 321

1 Answers1

0

Here are some notes. I do not have an old version to play around with, so I do not know if you can import more than you can export:

Dim ws As Workspace
Dim db As Object
Dim tdf As TableDef
Dim qdf As QueryDef
Dim dbExp As Database
Dim acApp As New Access.Application

acApp.OpenCurrentDatabase "z:\docs\demo.accdb"
Set dbExp = acApp.CurrentDb

Set ws = DBEngine.Workspaces(0)
FName = "z:\docs\oldver95.mdb"
''Access 95
Set db = ws.CreateDatabase(FName, dbLangGeneral, dbVersion30)
''You can only export tables and a limited range of datatypes
For Each tdf In dbExp.TableDefs
    If Left(tdf.Name, 4) <> "Msys" Then
        acApp.DoCmd.TransferDatabase acExport, "Microsoft Access", _
           FName, acTable, tdf.Name, tdf.Name
    End If
Next

See http://msdn.microsoft.com/en-us/library/office/bb243161(v=office.12).aspx

A few notes using VBScript to demonstrate using the engine:

Dim objEngine
Dim objWS
Dim objDB
Dim db: db = "z:\docs\oldver95.mdb"

Set objEngine = CreateObject("DAO.DBEngine.36")
Set objDB = objEngine.OpenDatabase(db)

strSQL="SELECT * FROM Table1"

objDB.CreateQueryDef "Query1", strSQL
Fionnuala
  • 90,370
  • 7
  • 114
  • 152
  • Ok, so you have to have Access installed on the machine? Would that be Access 2010? – CJ7 Feb 20 '13 at 11:05
  • You are working with the engine, and you could transfer the tables using queries instead of TransferDatabase, so you could use the free 2010 redistributables, rather than the full version of MS Access. (The test was in 2010) – Fionnuala Feb 20 '13 at 11:07