how do i send report by email upon closing database

A

Anna

I created a macro to automatically run a report to send to distribution list
via email. i am having to run the macro manually. I want for the macro to
run when i click on the exit database button. how do i do this?
 
A

Al Campagna

Anna,
What button are you referring to?
If you are using the Access database screen's File/Exit, or the X to
close,
there are no events associated with that, and consequently... no place to
code to
run a report.
Most database applications have some sort of startup form... like a
Main Menu, and an "Exit Application" button on that form could be used to
run the report just before closing the appplication, and Access.

Private Sub cmdExitApplication_Click()
DoCmd.OpenReport "YourReport"
DoCmd.Quit
End Sub
--
hth
Al Campagna
Microsoft Access MVP 2007-2009
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
S

Steve Schapel

Anna,

You have said that you already have the macro created.

So now, in design view of the form, select your command button, look at the
Properties, find the 'On Click' property, and from the drop-down list in
that On CLick property box, enter the name of your macro.
 

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