Problem exporting forms with DoCmd.TransferDatabase from an accde file.

jacky Perpète 41 Reputation points

Access 2021


In a database, from a button on a form, I create another database and export a table and a form to this new database. This functionality is in VBA code.

In the accdb file everything works perfectly.

I then create an accde file from the accdb file.

If I run the accde file, I get an error message about exporting the form.


The export of the table was carried out correctly.

Here is the VBA code:

Private Sub Commande0_Click()

Dim db As Database
Dim filePathDataBaseDestination As String
Const pathDataBaseDestination As String = "D:\Documents\Tempo"
Const nameDataBaseDestination As String = "NewDB.accdb"

filePathDataBaseDestination = pathDataBaseDestination & "\" & nameDataBaseDestination

'Check if we need to create the database
If Dir(filePathDataBaseDestination) = "" Then
	'Create the database
	Set db = DBEngine.Workspaces(0).CreateDatabase(filePathDataBaseDestination, dbLangGeneral)
	'Transfer the table
     DoCmd.TransferDatabase acExport, "Microsoft Access", filePathDataBaseDestination, acTable, "Table1", "TableNew", False
	'Transfer the form
     DoCmd.TransferDatabase acExport, "Microsoft Access", filePathDataBaseDestination, acForm, "Formulaire2", "Formulaire2", False
End If

End Sub
Access Development
Access Development
Access: A family of Microsoft relational database management systems designed for ease of use.Development: The process of researching, productizing, and refining new or existing technologies.
817 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. jacky Perpète 41 Reputation points


    I just found the info on:

    If the file is in ACCDE format, the source object must be a table, query, or macro. Forms, reports and modules cannot be exported.

    Unfortunately, this restriction is not explained in the help for the DoCmd.TransferDatabase method.

    The error message does not give good information for this restriction.

    0 comments No comments