Copy a form from DB1 to DB2 - How? (1 Viewer)

ian_w

Registered User.
Local time
Today, 05:04
Joined
Jun 13, 2006
Messages
64
Im trying to get my code to open a second DB instance, copy a form and paste it into the currentdb but I can't get it to work :eek:

So far I have this..

(currentdb = update.mdb)

Code:
Set wsp = CreateWorkspace("", "admin", "", dbUseJet)
Set db = wsp.OpenDatabase("C:\Application\StockDB.mdb")

DoCmd.CopyObject "J:\Dev\Update.mdb", "Main_Menu",   acForm, "Main_Menu"

When I run this I get "Access cannot find the object 'Main_Menu'.

I'm guessing that im just opening up the tables ?? How can I open up the entire db so I can copy the forms?
 

ian_w

Registered User.
Local time
Today, 05:04
Joined
Jun 13, 2006
Messages
64
Got it partially working now...

Code:
Dim oAcc2 As Access.Application

    Set oAcc2 = New Access.Application
    oAcc2.Visible = False
    oAcc2.OpenCurrentDatabase ("C:\Application\StockDB.mdb"), True
    oAcc2.DoCmd.CopyObject "J:\Dev\Update.mdb", "Main_Menu_Copy", acForm, "Main_Menu"
    oAcc2.CloseCurrentDatabase

Using the above code I can get the form copied but there are two problems:

1. I need to load the database in admin mode i.e design mode (not autoload the main menu as its set to.)

2. It will only let me copy the files if I change the name? I need to made exact copies which includes the name of the form.

Any tips on how I could get past these 2 small problems :)
 

Users who are viewing this thread

Top Bottom