copy forms and modules from one database to another (1 Viewer)

Jaye7

Registered User.
Local time
Today, 11:28
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
 

informer

Registered User.
Local time
Today, 03:28
Joined
May 25, 2016
Messages
75
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

;)
 

Jaye7

Registered User.
Local time
Today, 11:28
Joined
Aug 19, 2014
Messages
205
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.
 

informer

Registered User.
Local time
Today, 03:28
Joined
May 25, 2016
Messages
75
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

Top Bottom