Access 2013 does not support ADP. Some alternatives to ADPs are given:
- Convert the ADP to a linked Access Desktop Database.
- Import objects into an ACCDE file and then create linked tables to the existing data by using an earlier version of Access.
My ADP contains only Forms, Reports, Macros and Modules. I want to use this ADP in Access 2013 (not on any earlier version of Access).
I have not found any method to convert ADP to a linked Access Desktop Database or to Import objects into an ACCDE file on Access 2013.
How can I convert an ADP to a linked Access Desktop Database or to Import objects into an ACCDE file using Access 2013?
How can I convert an ADP to a linked Access Desktop Database or to Import objects into an ACCDE file using Access 2013?
You can't. Access 2013 won't work with ADP files at all. If you try to import objects from an ADP file in Access 2013, you get the following error:
What you need to do is
- find a machine with Access 2010 or earlier,
- use it to import the Queries, Forms, etc., from the ADP into an
.accdb
or.mdb
file, then - take that
.accdb
or.mdb
file back to your Access 2013 machine and continue on from there.
edit re: comments
Is there is no way to Convert the ADP to a linked Access Desktop Database using access 2013
Apparently not. Even trying to use VBA to copy a Form object from an .adp
file into an .accdb
file fails. The following code:
Option Compare Database
Option Explicit
Sub adpImportTest()
Dim dbPath As String, formName As String
On Error GoTo adpImportTest_Error
Debug.Print "Try importing a form from an .accdb file..."
dbPath = "C:\Users\Gord\Documents\accdbTest.accdb"
formName = "myCustomers"
DoCmd.TransferDatabase acImport, "Microsoft Access", dbPath, acForm, formName, formName
Debug.Print "Import succeeded."
Debug.Print
Debug.Print "Try importing a form from an .adp file..."
dbPath = "C:\Users\Gord\Documents\NorthwindCS.adp"
formName = "Customers"
DoCmd.TransferDatabase acImport, "Microsoft Access", dbPath, acForm, formName, formName
Debug.Print "Import succeeded."
Exit Sub
adpImportTest_Error:
Debug.Print Err.Description
End Sub
...produces the following result:
Try importing a form from an .accdb file...
Import succeeded.
Try importing a form from an .adp file...
The search key was not found in any record.
If we try to get sneaky and rename the .adp
file to .mdb
then Access 2013 won't read it:
As I said, you need to use Access 2010 (or older) to extract the objects from the .adp
file into an .accdb
or .mdb
file. Then you can work with the .accdb
or .mdb
file in Access 2013.
Using office<2013 eg 2010 2007
Try using save as text / load from text to transfer forms You can then edit the text files preparing recordsources for your accdb linked tables.
Partial and uncleaned code but gives you an idea
module LoadSaveForm:
Option Compare Database
Option Base 0
Option Explicit
Dim path$
Dim DateTimeString$
Dim app As Access.Application
Function SaveFormAsText(FormName As String) As Boolean
Dim sPath As String
Access.SaveAsText acForm, FormName, "C:\Temp" & "\" & FormName & ".txt"
End Function
Function LoadFormFromText(FormName As String)
Access.LoadFromText acForm, FormName, "C:\Temp" & "\" & FormName & ".txt"
End Function
Private Sub SaveMDBObjectsAsText()
DateTimeString = Format(Now(), "yyyymmddhhnn")
path = CurrentProject.path & "\" '& "AS_TEXT_" & DateTimeString & "\"
If Dir(path) <> "" Then
'It exists
Else
On Error Resume Next
MkDir path
On Error GoTo 0
End If
SaveDataAccessPagesAsText
SaveFormsAsText
SaveReportsAsText
SaveModulesAsText
'SaveQueriesAsText
CreateProjectFromText (path)
End Sub
Public Sub CreateProjectFromText(pathString As String)
path = pathString
'SaveMDBBase
SaveAccdbDBase
LoadDataAccessPagesFromText
LoadFormsFromText
LoadReportsFromText
LoadModulesFromText
'LoadQueriesFromText
On Error Resume Next
Dim r As Reference
With app
With .CurrentProject
path = .FullName
End With
For Each r In .References
With r
If Not .BuiltIn Then
app.References.Remove r
End If
End With
Next r
For Each r In References
With r
If Not .BuiltIn Then
app.References.AddFromGuid r.GUID, r.Major, r.Minor
End If
End With
Next r
.RunCommand acCmdSaveAllModules
.RunCommand acCmdCompileAndSaveAllModules
.CloseCurrentDatabase
.SysCmd 603, path, Replace(Replace(Replace(path, ".accdb", ".accde"), ".adp", ".ade"), ".mdb", ".mde")
.Quit
End With
Set app = Nothing
MsgBox "All Done with Text Backup"
End Sub
Private Sub SaveDataAccessPagesAsText()
Dim filename$
Dim Name$
Dim DataAccessPage As AccessObject
For Each DataAccessPage In CurrentProject.AllDataAccessPages
Name = DataAccessPage.Name
filename = path & Name & ".txt"
SaveAsText acDataAccessPage, Name, filename
Next DataAccessPage
End Sub
Private Sub SaveFormsAsText()
Dim filename$
Dim Name$
Dim Form As AccessObject
For Each Form In CurrentProject.AllForms
Name = Form.Name
filename = path & Name & ".txt"
SaveAsText acForm, Name, filename
Next Form
End Sub
Private Sub SaveReportsAsText()
Dim filename$
Dim Name$
Dim Report As AccessObject
For Each Report In CurrentProject.AllReports
Name = Report.Name
filename = path & Name & ".txt"
SaveAsText acReport, Name, filename
Next Report
End Sub
Private Sub SaveMacrosAsText()
Dim filename$
Dim Name$
Dim Macro As AccessObject
For Each Macro In CurrentProject.AllMacros
Name = Macro.Name
filename = path & Name & ".txt"
SaveAsText acMacro, Name, filename
Next Macro
End Sub
Private Sub SaveModulesAsText()
Dim filename$
Dim Name$
Dim Module As AccessObject
For Each Module In CurrentProject.AllModules
Name = Module.Name
filename = path & Name & ".txt"
SaveAsText acModule, Name, filename
Next Module
End Sub
Private Sub SaveQueriesAsText()
Dim filename$
Dim Name$
Dim GetQueryNames As ADODB.Recordset
Set GetQueryNames = CurrentProject.connection.OpenSchema(adSchemaViews)
With GetQueryNames
Do While Not .EOF
Name = .Fields("TABLE_NAME")
filename = path & Name & ".txt"
SaveAsText acQuery, Name, filename
.MoveNext
Loop
End With
End Sub
Private Function SaveAccdbDBase() As Database
Dim ws As DAO.Workspace
Dim db As DAO.Database
'Get default Workspace
Set ws = DBEngine.Workspaces(0)
Dim filename$
Dim Name$
Name = Replace(CurrentProject.Name, CurrentProject.path, "")
If Name Like "*.adp" Then
Name = Replace(Name, "adp", "accdb")
Else
Name = Replace(Name, "accdb", "adp")
End If
filename = path & Name
'Make sure there isn't already a file with the name of the new database
If Dir(filename) <> "" Then Kill filename
Set app = CreateObject("Access.Application")
'Create a new mdb file
If Name Like "*.adp" Then
Application.CreateAccessProject filename, getConnection.ConnectionString
Else
Set db = ws.CreateDatabase(filename, dbLangGeneral)
End If
db.Close
Set db = Nothing
'SaveAsText 6, "", filename
If Name Like "*.adp" Then
app.Visible = True
app.UserControl = True
app.OpenAccessProject filename
Else
app.OpenCurrentDatabase filename
End If
app.SetOption "Show Navigation Pane Search Bar", True
Set SaveAccdbDBase = db
End Function
Private Sub LoadDataAccessPagesFromText()
Dim filename$
Dim Name$
Dim DataAccessPage As AccessObject
For Each DataAccessPage In CurrentProject.AllDataAccessPages
Name = DataAccessPage.Name
filename = path & Name & ".txt"
app.LoadFromText acDataAccessPage, Name, filename
Next DataAccessPage
End Sub
Private Sub LoadFormsFromText()
Dim filename$
Dim Name$
Dim Form As AccessObject
For Each Form In CurrentProject.AllForms
Name = Form.Name
filename = path & Name & ".txt"
On Error Resume Next
app.LoadFromText acForm, Name, filename
Next Form
End Sub
Sub CreateNewMDBFile()
Dim ws As Workspace
Dim db As Database
Dim LFilename As String
'Get default Workspace
Set ws = DBEngine.Workspaces(0)
'Path and file name for new mdb file
LFilename = "c:\NewDB.mdb"
'Make sure there isn't already a file with the name of the new database
If Dir(LFilename) <> "" Then Kill LFilename
'Create a new mdb file
Set db = ws.CreateDatabase(LFilename, dbLangGeneral)
'For lookup tables, export both table definition and data to new mdb file
DoCmd.TransferDatabase acExport, "Microsoft Access", LFilename, acTable, "Lookup Table1", "Lookup Table1", False
'For data entry tables, export only table definition to new mdb file
DoCmd.TransferDatabase acExport, "Microsoft Access", LFilename, acTable, "DataEntry Table1", "DataEntry Table1", True
db.Close
Set db = Nothing
End Sub
Run SaveMDBObjectsAsText() to get an idea of what happens
来源:https://stackoverflow.com/questions/19807031/how-to-convert-an-adp-to-accdb-using-access-2013