Access 2021
Hello,
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
db.Close
End If
End Sub