Too bad! using an errorhandler takes some rudimentary VBA knowledge. I was
trying to find an example .mdb file with some basic error handling code, but
all my stuff has been highly modified. Lets try something simpler with no
logging and no automatic error handling. Use this example in all your
routines:
Sub Example()
'Put your variable declaration here!
On Error GoTo HandleErr
'Put your code here!
ExitHere:
Exit Sub
HandleErr:
Select Case Err.Number
Case 2501
Resume Next
Case 2502
Resume
Case Else
MsgBox "Error " & Err.Number & ": " & Err.Description, vbCritical,
"Form_frmDialog.test"
Resume ExitHere
End Select
End Sub
In the select case we are grabbing specific error numbers (i.e., 2501) and
telling the code to Resume Next with the next line (following the line with
the error) of code in the body. Or, for other error numbers (i.e., 2502) we
are saying try the line with the error again (only for errors which you know
are repeatable which will most likely will be none). The Case Else prints
the error showing the form name and routine name in the msgbox title then
goes to the ExitHere block. You could use a "Resume ExitHere" without a
msgbox to quit the routine without displaying the error message, but then
you wouldn't know why the routine aborted in mid-step. The "Resume Next" is
valuable for errors like 2501, "The RunCommand action was canceled." where
the cancel was a user response and error message need not be displayed and
you want to continue with the next line of code.
You can add a logging routines and errorhandling routines when you have
become more familiar with VBA coding. I would suggest a good book on Access
programming, before you buy one, check the index for error handling
chapters.
2005 >>>
I am not that good with vba should I add that to a module
or in a form level script?
Thanks
Odbodypierre
-----Original Message-----
You should NOT have a general policy to log all errors then move on as if
there were no error. You need to also have a errorhandler table to specify
the action to be taken for each error. I would suggest both error log AND
an error handler table, to use code like the following example in every
routine with more than one line of code:
Function GetScreenResolution() As String
'******************************************************** *******************
**********************
' FUNCTION: GetScreenResolution()
' PURPOSE: To determine the current screen size or resolution.
' RETURNS: The current screen resolution.
' Typically one of the
following: '640x480', '800x600',