Send email only when query or report has data

Jmsteph

Registered User.
Local time
Today, 12:08
Joined
Dec 2, 2008
Messages
28
Hello,

I have a macro that runs each night to email files and do other misc things on the database. The only thing is that I have a query that it e-mails each night that very rarely has data on it. I'd like for it to only send the e-mail when there is data in the query so that I don't overwhelm the recipients with pointless emails. Has anyone come up with a way to do this?
Thanks,
 
Do you say you are using a MACRO or VBA code (since you posted in the VBA /MODULES area)?

For VBA you can use something like this:

Code:
If DCount("*", "yourQueryNameHere") > 0 Then
   ' ...do your stuff here
End If
 
That will do it. I have the macro call the nightly cycle, but I can have it send the email through VBA so that works.
Thanks,

JS
 
You can run a macro from VBA:

DoCmd.RunMacro "MacroNameHere"
 

Users who are viewing this thread

Back
Top Bottom