copy forms and modules from one database to another

Jaye7

Registered User.
Local time
Tomorrow, 01:43
Joined
Aug 19, 2014
Messages
205
I am trying to copy a form from one database to another PASSWORD protected database.

The following will open the database but I get an error as the file already exists.

Runtime error 2007 - you already have a database object named frm_Utilities.

I tried the Docmd.transfer method but it always requests the password even though I specify it.

Code:
DoCmd.SetWarnings False
        DoCmd.CopyObject "X:\Test1\TestFile1.mdb", _
                     "frm_Utilities", acForm, "frm_Utilities" 'script before acform refers to this dbase, after to the other
 
    DoCmd.SetWarnings True
 
Hi Jaye7

I tested this code, it works :
Code:
DoCmd.TransferDatabase acImport, "Microsoft Access", "D:\..\DataBaseSourceName.accdb", acForm, "ObjectNameSource", "ObjectNameTarget"
To go further read msdn.microsoft.com/fr-fr/library/office/ff196455.aspx

;)
 
Thanks for your reply,

It does work if I import the form into the database but what I am trying to do is copy the form from an open database to around 12 other databases without having to open them all.
 
Hi Jaye7

To export forms from an active database, you need to close all opened forms so before calling

Code:
DoCmd.TransferDatabase acExport, "Microsoft Access", "D:\...\DatabaseTarget.accdb", acForm, "frmActiveDbName", "frmTargetName"
add this code

Code:
 Do While Forms.Count > 0
        DoCmd.Close acForm, Forms(0).Name
Loop

code complete
Code:
 Do While Forms.Count > 0
        DoCmd.Close acForm, Forms(0).Name
Loop
DoCmd.TransferDatabase acExport, "Microsoft Access",  "D:\...\DatabaseTarget.accdb", acForm, "frmActiveDbName",  "frmTargetName"
If there are a Access target db list, create a table with their name and path and code a loop procedure
 

Users who are viewing this thread

Back
Top Bottom