Search code examples
ms-accessvba

How to copy a report or form from one Access database to another?


I made a form in a database that I wanted to copy to another MS Access database. I can copy and paste the form design but seems like even though all the fields are copied the form width and spacing is messed up. Is there another way to copy the form design from one database to another?


Solution

  • Also you can use Application.DoCmd.TransferDatabase :

    DoCmd.TransferDatabase acImport, "Microsoft access", "C:\sourceDB.mdb", acForm ,"SourceFormName", "FormNameInDestinationDB"
    

    Or less handy two steps:

    1. Export in source DB

      Application.saveAsText acForm ,"SourceFormName", "C:\fileWithForm.txt"

    2. Import in destination DB

      Application.LoadFromText acForm ,"FormNameInDestinationDB", "C:\fileWithForm.txt"