' strCallingProc - name of sub|function that generated the error. ' strErrDescription - value of Err.Description ' Arguments: lngErrNumber - value of Err.Number StrCallingProc As String, Optional vParameters, Optional bShowUser As Boolean = True) As Boolean You can also opt to suppress the display of information about the error.įunction LogError(ByVal lngErrNumber As Long, ByVal strErrDescription As String, _ It optionally allows recording the value of any variables/parameters at the time the error occurred. Any parameters you wish to record.īelow is a procedure for writing to this table. Whether error data was displayed in MsgBoxĢ55. The table might be named "tLogError" and consist of: Field Name This allows you to review the details after the error has been cleared. The Case Else in this example calls a custom function to write the error details to a table. Resume Exit_SomeName ' Use this to give up on the proc.Ĭall LogError(Err.Number, Err.Description, "SomeName()") Resume Next ' Use this to just ignore the line. Each procedure, then, will have this format (without the line numbers): 1 Sub|Function SomeName()Ģ On Error GoTo Err_SomeName ' Initialize error handling.Ĥ Exit_SomeName: ' Label to resume after error.ĥ Exit Sub|Function ' Exit before error handler.Ħ Err_SomeName: ' Label to jump to on error.ħ MsgBox Err.Number & Err.Description ' Place error handling here.Ĩ Resume Exit_SomeName ' Pick up again and quit.įor a task where several things could go wrong, lines 7~8 will be replaced with more detail: Select Case Err.NumberĬase 9999 ' Whatever number you anticipate. The simplest approach is to display the Access error message and quit the procedure. For a more detailed approach to error handling, see FMS'
#Access label wizard error full version#
Without it, a user mayīe left viewing the faulty code in a full version of Access, while a run-time Updated September 2009.Įvery function or sub should contain error handling. Microsoft Access tips: Error Handling in VBA Microsoft Access Tips for Serious Users