Hi,
I'm trying to polish my MSAccess VBA code by introducing error logging. I discovered a way to log the errors to an external file. The example showed how to pass the error message to a Sub which logs the info to a file. Obviously I can also pass the error number as well if I choose. The following is the code I found which is called from each 'On Error' handler section of the Sub or Function.
But I'm at a loss as to how to pass to the error log, the source of the error. By that I mean which Sub or Function, from which form/report/module caused the error.
Is there a way to extract the Sub/Function/Module name source so I can pass it to the logging Sub?
Thanks,
Vic
I'm trying to polish my MSAccess VBA code by introducing error logging. I discovered a way to log the errors to an external file. The example showed how to pass the error message to a Sub which logs the info to a file. Obviously I can also pass the error number as well if I choose. The following is the code I found which is called from each 'On Error' handler section of the Sub or Function.
Code:
Sub LogError(msg As String)
Dim fileName As String, fileNo As Integer
fileNo = FreeFile [COLOR=#4E9A06]'Get first free file number[/color]
fileName = "f:\DBMS\error_log.txt"
Open fileName For Append As #fileNo
Print #fileNo, Now & ":" & msg
Close #fileNo
End Sub
But I'm at a loss as to how to pass to the error log, the source of the error. By that I mean which Sub or Function, from which form/report/module caused the error.
Is there a way to extract the Sub/Function/Module name source so I can pass it to the logging Sub?
Thanks,
Vic