Email Query Results

mlr0911

Registered User.
Local time
Today, 15:06
Joined
Oct 27, 2006
Messages
155
Hello,

I have the following code kicking off an email based on a query result:
Code:
DoCmd.SendObject acSendReport, "Transaction Notice", acFormatTXT, "jams@corwell.com", "sweeny@corwell.com", , "Transaction Notice", "The following fees were reported on today's report." & Chr(13) & Chr(13) & _
Chr(13) & Chr(13) & "Thank You" & Chr(13) & Chr(13)

What I need help with is if the above report (query) doesn't have any data, don't send the email.

How would I accomplish this?

Thanks for your help.
 
you could do a

Code:
if isnull(yourdatefield) then
msgbox "please enter a date"
else
DoCmd.SendObject acSendReport, "Transaction Notice", acFormatTXT, "jams@corwell.com", "sweeny@corwell.com", , "Transaction Notice", "The following fees were reported on today's report." & Chr(13) & Chr(13) & _
Chr(13) & Chr(13) & "Thank You" & Chr(13) & Chr(13)
end if
 
rainman thanks for your help......
 
hmm if x = > 1 then run qry ???

so run your qry with a total in it and if that field is >1 then run qry
if its not then don't ?

thinking out loud here really
 
Use the Dsum on the reports recordsource to count the records. If the value returned is greater than zero send the email.
 
you could do a

Code:
if isnull(yourdatefield) then
msgbox "please enter a date"
else
DoCmd.SendObject acSendReport, "Transaction Notice", acFormatTXT, "jams@corwell.com", "sweeny@corwell.com", , "Transaction Notice", "The following fees were reported on today's report." & Chr(13) & Chr(13) & _
Chr(13) & Chr(13) & "Thank You" & Chr(13) & Chr(13)
end if


Could you help me to understand what's happening in this code? I have little programming experience. What's happening here. It looks like it will send an email when certain criteria is met.
 
Could you help me to understand what's happening in this code? I have little programming experience. What's happening here. It looks like it will send an email when certain criteria is met.

thats correct,
its checking to see if there is a date in the field, which would mean the qry has data in it then it is sending the email to the specified people
 

Users who are viewing this thread

Back
Top Bottom