The macro is calling macros from other databases, then updating the final
results into a "final" table. This "final" database is where the macro is
stored.
Actual code with path and macro names changed:
Public Function Append_Data()
DoCmd.SetWarnings False
'Call Sub Databases Macros
Call Sub_Macros
DoCmd.OpenQuery "macro1"
DoCmd.OpenQuery "macro2"
'Turn warnings back on
DoCmd.SetWarnings True
'Close Access
DoCmd.Quit
End Function
Public Function Sub_Macros()
'Number of macros
Const NumberofMacros = 2
'Database/Macro Name List
Dim DatabaseName(0 To NumberofMacros) As String
Dim MacroName(0 To NumberofMacros) As String
'Database Path list
DatabaseName(0) = "path to database"
MacroName(0) = "macro inside database1"
DatabaseName(1) = "path to database"
MacroName(1) = "macro inside database2"
'Declare the variables
Dim AccessApp As Object
Dim i As Integer
'*************************************************************************************
'Database/Macro Loop
'*************************************************************************************
For i = 0 To NumberofMacros - 1
'Open the Database
Set AccessApp = GetObject(DatabaseName(i), "Access.Application")
'Run the macro
AccessApp.DoCmd.RunMacro MacroName(i)
'Close the Application
AccessApp.Quit
Next i
What is the Macro doing? What is it looping through? Are you trying to exit?
[quoted text clipped - 6 lines]