Report Send through Auto Email

mlr0911

Registered User.
Local time
Today, 15:06
Joined
Oct 27, 2006
Messages
155
I have a report that suppresses if it has not data in it (cancel=true.....do nothing). However, I am trying to send the report through sendobject and it works well until there isn't any data to display.Great! it works, however, it throws an error message asking me if I want to end or debug. How can I trap only that message referring to the report on open event to bypass that error message?

Thanks
mlr0911
 
It seams like you're reading out of bounds here.

I can't do this in Access but I can give an example in pseudocode:

Error:

for i = 1 to count(records) do
begin
end

Correct version

for i = 0 to count(records)-1 do
begin
end

Since computer programs often count from 0 to 9 instead from 1 to 10 as we humans do this error acures. Tell me if you need more help.
 
I suspect you want to trap for error 2501.
 
Yes, I am trying to capture or Trap error 2501

I was trying to use
Code:
if err.number=2501 then
' Do nothing
else
docmd.sendobject acsendreport,"................"

But it isn't trapping the error.
 
The error is being caused by the following code>
Code:
DoCmd.SendObject acSendReport, "Transaction Notice", acFormatTXT, "", "", , "Transaction Notice", "The following dividends and fees were reported on today's report." & Chr(13) & Chr(13) & _
Chr(13) & Chr(13) & "Thank You" & Chr(13) & Chr(13)

I have code in my report (cancel=true) on the NoData event to not open if there isn't any data. I have searched and played with my error handling code to try and trap the 2501 error but I haven't been successful.
Code:
exit_err_handle:
Exit Sub
Err_handle:
If Err.Number=2501 then
Resume exit_err_handle:
end if
 

Users who are viewing this thread

Back
Top Bottom