rye004
asked on
Adding queries and macros to many Microsoft Access Databases.
I have 50 Microsoft Access databases. Each of these databases are in the same structure.
I have 20 queries and 5 macros that I want to add to each of these. I wanted to know if there is an automated way to add these 20 queries and 5 macros to each of the 50 access databases.
I was going to look into using COM Automation and .NET, but thought I would check her first to see if there was another way to do this.
Thanks in advance!
I have 20 queries and 5 macros that I want to add to each of these. I wanted to know if there is an automated way to add these 20 queries and 5 macros to each of the 50 access databases.
I was going to look into using COM Automation and .NET, but thought I would check her first to see if there was another way to do this.
Thanks in advance!
If you have split (FE/BE) databases, just push out a new FrontEnd database, replacing the target databases.
Sounds like you have 50 spreadsheets rather than 50 databases. Why is the data not all in the same database? Even if you kept 50 separate BE's, you could still use a single FE and simply relink to the BE you need.
Create a loop that populates strFileName and either hard-code the list of objects or create another loop that picks them out and formats the export statement based on object type.
Create a loop that populates strFileName and either hard-code the list of objects or create another loop that picks them out and formats the export statement based on object type.
DoCmd.TransferDatabase acExport, "Microsoft Access", strFilename, acMacro, "mOpenAuditOverviewReport", "AutoExec", False
DoCmd.TransferDatabase acExport, "Microsoft Access", strFilename, acQuery, "qOtherComments", "qOtherComments", False
DoCmd.TransferDatabase acExport, "Microsoft Access", strFilename, acReport, "srptOtherComments", "srptOtherComments", False
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try this:
source database dbs.accdb contains Queries and macros to be copied to destination databases.
Destination databases: d1.accdb, d2.accdb, ...
run copyObjects.accdb database and run form1, and click button.
copyObjects.zip
source database dbs.accdb contains Queries and macros to be copied to destination databases.
Destination databases: d1.accdb, d2.accdb, ...
run copyObjects.accdb database and run form1, and click button.
copyObjects.zip
ASKER
This is impressive, thank you. The VBA Macro in it is awesome.
Welcome!
- create a db (db1) and place these codes in a module
the code should copy the Query and Macro from db3 (source db of query and macro)
db2 will be destination db (you need to create a list of the 50 db, path and db names. you can place the names of the dbs in a table in db1)
Sub CopyObjects()
Dim acc As Object
Set acc = CreateObject("Access.Appli
acc.OpenCurrentDatabase CurrentProject.Path & "\db2.mdb"
' acc.DoCmd.TransferDatabase
acc.DoCmd.TransferDatabase
acc.CloseCurrentDatabase
Set acc = Nothing
End Sub