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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running Access Macro using VB 1

Status
Not open for further replies.

aarondewberry

IS-IT--Management
Jul 20, 2005
148
GB
Hi all

I have this code to open up access, using VB in Business Objects, and to run a macro.

Code:
Public Sub OpenAccess()

Dim app As Access.Application
Set app = CreateObject("Access.Application")

app.OpenCurrentDatabase ("*** Your database path in here ***")
app.Visible = True
app.DoCmd.RunMacro ("M1")

Set app = Nothing

End Sub

Heres the trick, the access database is already open when I use this code, so it opens up a second instance of the same database... confusing.
How can I modify this code to just switch back to the open access database and then run the macro?

Hope this is clear!
 
Just to add.. I can't close the open DB and then re-open it.

Regards
 
Use GetObject instead of CreateObject.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top