Is there a way to write code in one database (db1) so that when I open another known database (db2) it will run a query that I specify at startup ? The query is created in db1 and I have written vb code to copy it over to db2. However, because of the complexity of my database I need to automate the process of running the query from within db1. I have played around with creating an AutoExec macro in db1 and copying it over to db2 , but I don't want the macro to run in db1, just db2. If I delete the macro from within db1, I will not be able to use it again when I want to create a new database (db3).