Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running a macro in a another database

Status
Not open for further replies.

rushdib

Programmer
Jun 12, 2001
203
US
Hi,
How do I run a macro in a different Access database?

Thank You,

Rushdi
 
Hi Rushdi,
This sounded like a fun problem that I've never tried, so I wrote you a method and tested it. You'll want to customize it's response and add some error-handling. I suggest making it a function that returns a boolean so that the calling method can just see if it was successful or not. Enjoy!

DoogieB

PS-I wrote this using Access 2000. If you're using '97 the object model will likely be different, but this will at least give you the general idea.

Public Sub RunRemoteMacro(ByVal strDbPath As String, ByVal strMacroName As String)
Dim app As Access.Application
Set app = CreateObject("Access.Application")
app.OpenCurrentDatabase strDbPath
app.DoCmd.RunMacro strMacroName
app.CloseCurrentDatabase

Set app = Nothing

MsgBox "Macro " & strMacroName & " has been run"
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top