Running Macro In Another Database

CJBIRKIN

Drink!
Local time
Today, 00:34
Joined
May 10, 2002
Messages
255
Hello

I have written this in an attempt to run a macro in another database. I have been able to enumerate through the objects in this database with a for each container and document loop and i have "seen" the macro in question but i am unable to run it. I get an error message saying " MS ACCESS CANNOT FIND THE MACRO AUTOEXEC1"

does anyone have any clues??

Cheers

Chris

Private Sub CMD_WAITINGLISTLOAD_Click()
On Error GoTo Err_CMD_WAITINGLISTLOAD_Click

Dim ws As DAO.Workspace
Dim db As DAO.Database
' Create Microsoft Jet Workspace object.
Set ws = CreateWorkspace("", "admin", "", dbUseJet)

' Open Database object from saved Microsoft Jet database for exclusive use.
Set db = ws.OpenDatabase("H:\NEWWAITINGLIST\MONTHLY-WAITING-LIST-MANAGER.mdb", True)

With db
DoCmd.RunMacro ("AUTOEXEC1")
End With

Set db = Nothing
Set ws = Nothing

Exit_CMD_WAITINGLISTLOAD_Click:
Exit Sub

Err_CMD_WAITINGLISTLOAD_Click:
MsgBox Err.Description
Resume Exit_CMD_WAITINGLISTLOAD_Click

End Sub
 
First glance impression.... (so I have no idea if what I'm saying is true) but, shouldn't you have a (.) dot modifier before DoCmd?

With db
.DoCmd.RunMacro ("AUTOEXEC1")
End With

Otherwise the code will assume you're calling the macro from your current database.
 

Users who are viewing this thread

Back
Top Bottom