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!

Code to launch a query for Access DB (not the one code running from)

Status
Not open for further replies.

ChrisOjeda

Programmer
Apr 16, 2003
45
US
I want to launch an Access DB query but the query resides in a different Access DB than the one I am running my code from? Any ideas? Chris
 
Hi Chris,

To the best of my knowledge you need to use a separate workspace for each database you are using. I posted some code for this in thread702-558955 which should get you started.

Enjoy,
Tony
 
Tony,

I tried using your commands but it won't compile. I have Access 2000.

Turns out I only need to run a macro... can anyone help?
 
Sorry, Chris,

What problem do you have compiling? Are you missing a reference to DAO? I have Access 2K as well and it works for me.

Tony
 
TJ,

Thanks for the follow up. This compiles below but I get an error message that Macro temp can not be found. That means it is trying to run the macro out of the database I am running the code from and NOT the other database. I am sure that your workspace and database parts work perfect. I just need to now run that macro. Any more ideas? Thanks for all the help so far... Chris

Private Sub cmdUpdate()
Dim wksWorkspace As DAO.Workspace
Dim dbDatabase As DAO.Database

Set wksWorkspace = CreateWorkspace("Chris", "admin", "")
Set dbDatabase = wksWorkspace.OpenDatabase("T:\Default_Project\FC_Impact_Analysis\FC_Impact_Analysis.mdb")

DoCmd.RunMacro "temp"

dbDatabase.Close
wksWorkspace.Close

Set dbDatabase = Nothing
Set wksWorkspace = Nothing

End Sub
 
Hi Chris,

I'm afraid, for the second time this evening, I have to say I don't know. I've just had a look at the help and DoCmd.RunMacro only runs a macro in the current database and there is no indication of how to run one in another database, and everything I've tried has failed. Can you run your query without the macro?

Maybe someone else out there knows how or can confirm it's not possible.

Sorry not to be more help.

Enjoy,
Tony
 
Tony,

No problem... you were a big help... I am all the more closer. I can run the three queries instead of the macro. However, is there special coding to do this for a remote database???
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top