In your code below, can "ALLForms, AllMacros, etc. be used as variables in
"CurrentProject" to reuse the same code?
>> I want to export all objects from one mdb to another. I can think of
>> a way to export tables and queries looping through the querydefs and
[quoted text clipped - 22 lines]
>
> Next ao
> In your code below, can "ALLForms, AllMacros, etc. be used as
> variables in "CurrentProject" to reuse the same code?
Not readily. The best I've been able to figure out is something like
this:
'----- start of code -----
Sub ExportObjects(ot As AcObjectType, OutFile As String)
Dim c As AllObjects
Dim ao As AccessObject
Select Case ot
Case acForm: Set c = CurrentProject.AllForms
Case acReport: Set c = CurrentProject.AllReports
Case acModule: Set c = CurrentProject.AllModules
Case acMacro: Set c = CurrentProject.AllMacros
Case acDataAccessPage: Set c = CurrentProject.AllDataAccessPages
Case acTable: Set c = CurrentData.AllTables
Case acQuery: Set c = CurrentData.AllQueries
Case Else
Err.Raise 5, "ListCollection", "Unsupported object type"
End Select
For Each ao In c
DoCmd.TransferDatabase _
acExport, _
"Microsoft Access", _
OutFile, _
ot, _
ao.Name, _
ao.Name
Next ao
Set c = Nothing
End Sub
'----- end of code -----
You'd then call it like this:
ExportObjects acForm, "C:\Temp\Output.mdb"
ExportObjects acReport, "C:\Temp\Output.mdb"
ExportObjects acModule, "C:\Temp\Output.mdb"
ExportObjects acMacro, "C:\Temp\Output.mdb"
ExportObjects acDataAccessPage, "C:\Temp\Output.mdb"
ExportObjects acTable, "C:\Temp\Output.mdb"
ExportObjects acQuery, "C:\Temp\Output.mdb"

Signature
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)
Dirk Goldgar - 03 Dec 2006 19:19 GMT
Correction to code: you should change this line ...
> Err.Raise 5, "ListCollection", "Unsupported object type"
... to something like this ...
> Err.Raise 5, "ExportObjects", "Unsupported object type"
... so as to reflect the correct name of the procedure.

Signature
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)