'Procedure used to promp unexpected errors
Public Sub prompt_err(ByVal sError As ErrObject, ByVal ModuleName As String, ByVal OccurIn As String, Optional PrompMSG As Boolean = True)
Dim s1, s2, s3, s4, s5 As String
Dim ff As Integer
ff = FreeFile
s1 = ModuleName
s2 = OccurIn
s3 = sError.Number
s4 = sError.Description
'* Store our line # where error Occured (always 0 when line # is not use)
s5 = IIf(Erl <> 0, CStr(Erl), vbNullString)
If PrompMSG = True Then
MsgBox "Error From" & Chr(9) & ": " & s1 & vbNewLine & _
"Occur In" & Chr(9) & Chr(9) & ": " & s2 & vbNewLine & _
"Error Number" & Chr(9) & ": " & s3 & vbNewLine & _
IIf(s5 <> vbNullString, "Line #" & Chr(9) & Chr(9) & ": " & s5 & vbNewLine, vbNullString) & _
"Description" & Chr(9) & ": " & s4, vbExclamation, s2 & " Error"
End If
'Save the error log (The save error log will be display later on in the program)
Open App.Path & "\Error.log" For Append As #ff
Print #ff, "*******************************************"
Print #ff, "Error From : " & s1
Print #ff, "Occured In : " & s2
Print #ff, "Date : " & Format(Date, "MMM-dd-yyyy")
Print #ff, "Time : " & Time
Print #ff, "Error # : " & s3
'* Check if Line # is not Null
If s5 <> vbNullString Then
Print #ff, "Line # : " & s5 '* Print Line No error
End If
Print #ff, "Description: " & s4
Print #ff, "*******************************************"
Close #ff
End Sub