Run Macro problem

G

Guest

Dear Sirs,
I have a "Main switchboard" in a DB which is organizing links to 5 different
Db's.
At the end of each month I have to set some tables of those 5 DB's to zero
(means to delete all records).
I would like to do this, in running a Marco with delete queries. If I do
that from each DB seperately it's working. I would like to run the Macros
from those different DB's from one command button on the "Main switchboard"
DB (that means, running Macros from 5 different DB's).
I tried to import the Macros from the different DB's into the "main
switchboard" but, logically, it cannot find the underlying queries (because
they are in another DB).
Can someone tell me how to run a Macro from a DB, out of a different DB?
If that is not posssible at all, can someone tell me which way I have to
think to get my result?
Thanks
Klaus
 
G

Guest

Dear Pieter
I have not received any answer to this question before - I just looked at my
recent posts and I cannot find anything which is giving me a hint.
I normally do not post anything twice if I received an answer, because I
print out every closed post (that you can see in my history).
If it doesn't create too many problems please be as kind as to answer this
post
Thanks
Klaus
 
P

Pieter Wijnen

ok, then, maybe it was somebody else with the same problem.
you can try to shell out

shell("<path to msaccess.exe> <path to oher db> /x<macro name>")

if the macro's only contain queries that need to be run it's better to run a
bit of code

Public Function RemoteQuery(RdbName As string, RqdName as string) As Long

Dim Rdb AS DAO.Database
Dim RQd As DAO.QueryDef

Set Rdb = Access.DbEngine.Workspaces(0).OpenDatabase(RdbName)
Set RQd = Rdb.QueryDefs(RQdName)
RQd.Execute DAO.DbFailOnError
RemoteQuery = RQd.RecordsAffected
RQd.Close : Set Rqd = Nothing
RDb.Close : Set Rdb = Nothing
End function

This can be placed in a (new) General module

hth

Pieter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top