Kamis, 30 Juli 2015

Re: [MS_AccessPros] automatic email to Manager an error trap from MsAccess 2010/2013

 

Norbert-


You can't just "fall out" of the end of your code when you've trapped an error.  Your code should look something like this:

Public Sub …

On Error GoTo ErrorTrap

' main code here


ExitSub:
    Exit Sub

ErrorTrap:
    MsgBox "Error " & Err.Number & " (" & Err.Description & ") in Procedure …"
    Call SendErrEmail

    ' This is IMPORTANT:
    Resume ExitSub
End Sub

When you fail to use Resume, you leave the error "hanging" - and further errors won't be trapped.

John Viescas, Author
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
SQL Queries for Mere Mortals 
(Paris, France)




On Jul 30, 2015, at 1:13 PM, drnorbert@msn.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:

I have a large accdb linked to SQL server which runs about 500 procedures (a form cmd runs an "EOD Procedure" (End Of Day) during the evening generating reports, letters, exports, imports.

The "EOD Procedure" takes from 2 to 6 hours the time depending of which day of the month is executed.
 
All the Public Procedures, Sub Procedures (Reports,etc) and Public Functions contain error handlers.
such as this sample:   


Public Sub ClientLetter()
On Error GoTo ClientLetter_Error
...........................................................................

 
On Error GoTo 0
Exit Sub

ClientLetter_Error:
    MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure ClientLetter of Module ModPublic"
End Sub


When an error occurs for any reason the EOD stops generating an Error msg.


The mission is to send an email to the Manager if the EOD stops due to any error (Null value, file not found, etc.).


This accdb has the capability to send emails for example if a client has an email then then via automation with Outlook the email is sent to the client attached a PDF file (Converted from the reports created by the EOD).


Please advise me if you have some suggestion how to approach this interested issue.


By the way in SQL I have a procedure which sends an email when a backup fails.


Norbert






__._,_.___

Posted by: John Viescas <johnv@msn.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)

.

__,_._,___

Tidak ada komentar:

Posting Komentar