If you want the queries to run when the application first open, you can
create a function that runs your queries and call that function from a macro
named AutoExec (or you can simply run the queries in the AutoExec macro). If
it exists, the AutoExec macro always runs as soon as the application opens.
The other option is to create a form that runs the queries through its Load
event. You can then set that form to open when the application opens
(through Tools | Startup in the menu, assuming Access 97 through 2003)
If you want the queries to run when the application closes, you have to use
the technique I mentioned, which is to put the code that runs the queries in
a form's Close event, and then make sure that form is always open. You can
open a form and not make it visible using the OpenForm action in the
AutoExec macro.