Greetings,
I have an application that I am trying to create some error handlign. I raise an error 513 when the status in the properties of a particular file is invalid. And a nother error is raised (613) when the version of the template (xls) file isn't the same as the access database version it is expected to work with.
For some reason it is as if the err.description isn't specifically tied to either of the err.numbers becasue regardless of which one I raise the message is that of the last error I defined.
Here is the code that defines my errors:
Err.Number = vbObjectError + 513 'Invalid Template Status
Err.Source = "EPSI Auto Open"
Err.Description = "Invalid Template Satus." & vbCrLf & vbCrLf & _
"The EPSI Tag Template has an invalid" & vbCrLf & _
"or missing status in its file properties." & vbCrLf & vbCrLf & _
"It must be one of the following:" & vbCrLf & _
"Dev, Test, Prod, or Pub"
Err.Number = vbObjectError + 613 'Invalid Template version
Err.Source = "EPSI Auto Open"
Err.Description = "Versions out of Sync." & vbCrLf & vbCrLf & _
"The EPSI Template version number does not match" & vbCrLf & _
"the verion number of the EPSI Software." & vbCrLf & vbCrLf & _
"Make sure you are using the approved version of the template." & vbCrLf & _
"The approved version resides in the folder with the EPSI software."
I raise the error with:
Select Case Stat$
Case Is = "Dev"
SWPath$ = DevDir
Case Is = "Test"
SWPath$ = TstDir
Case Is = "Prod"
SWPath$ = ProdDir
Case Is = "Pub"
SWPath$ = Published
Case Else
Err.Raise Number:=vbObjectError + 513
End Select
I handle the error like this:
Clean_Up:
If Not IsNull(db) Then
db.Close
End If
Set ws = Nothing
Set db = Nothing
Set rsWD = Nothing
Set rsV = Nothing
If errflag = True Then
Application.Quit
End If
errflag = Empty
Exit Sub
ErrorHndlr:
MsgBox Err.Number 'Troubleshooting only
If Err.Number <> 0 Then
'Case Is = 53
' MsgBox "You must use the template that resides with the EPSI software.", vbCritical + vbOKOnly, _
' "TEMPLATE ERROR"
' db.Close
MsgBox Err.Number - vbObjectError & " " & Err.Source & vbCrLf & vbCrLf & _
Err.Description & vbCrLf & SWPath$ & vbCrLf & vbCrLf & _
"If you need assistance contact Acquisiton Automation (BPS)", vbCritical + vbOKOnly, "ERROR"
Err.Clear
errflag = True
End if
GoTo Clean_Up
S J E
If I am not learning, then I am coasting, if I am coasting I must be going down hill.
I have an application that I am trying to create some error handlign. I raise an error 513 when the status in the properties of a particular file is invalid. And a nother error is raised (613) when the version of the template (xls) file isn't the same as the access database version it is expected to work with.
For some reason it is as if the err.description isn't specifically tied to either of the err.numbers becasue regardless of which one I raise the message is that of the last error I defined.
Here is the code that defines my errors:
Err.Number = vbObjectError + 513 'Invalid Template Status
Err.Source = "EPSI Auto Open"
Err.Description = "Invalid Template Satus." & vbCrLf & vbCrLf & _
"The EPSI Tag Template has an invalid" & vbCrLf & _
"or missing status in its file properties." & vbCrLf & vbCrLf & _
"It must be one of the following:" & vbCrLf & _
"Dev, Test, Prod, or Pub"
Err.Number = vbObjectError + 613 'Invalid Template version
Err.Source = "EPSI Auto Open"
Err.Description = "Versions out of Sync." & vbCrLf & vbCrLf & _
"The EPSI Template version number does not match" & vbCrLf & _
"the verion number of the EPSI Software." & vbCrLf & vbCrLf & _
"Make sure you are using the approved version of the template." & vbCrLf & _
"The approved version resides in the folder with the EPSI software."
I raise the error with:
Select Case Stat$
Case Is = "Dev"
SWPath$ = DevDir
Case Is = "Test"
SWPath$ = TstDir
Case Is = "Prod"
SWPath$ = ProdDir
Case Is = "Pub"
SWPath$ = Published
Case Else
Err.Raise Number:=vbObjectError + 513
End Select
I handle the error like this:
Clean_Up:
If Not IsNull(db) Then
db.Close
End If
Set ws = Nothing
Set db = Nothing
Set rsWD = Nothing
Set rsV = Nothing
If errflag = True Then
Application.Quit
End If
errflag = Empty
Exit Sub
ErrorHndlr:
MsgBox Err.Number 'Troubleshooting only
If Err.Number <> 0 Then
'Case Is = 53
' MsgBox "You must use the template that resides with the EPSI software.", vbCritical + vbOKOnly, _
' "TEMPLATE ERROR"
' db.Close
MsgBox Err.Number - vbObjectError & " " & Err.Source & vbCrLf & vbCrLf & _
Err.Description & vbCrLf & SWPath$ & vbCrLf & vbCrLf & _
"If you need assistance contact Acquisiton Automation (BPS)", vbCritical + vbOKOnly, "ERROR"
Err.Clear
errflag = True
End if
GoTo Clean_Up
S J E
If I am not learning, then I am coasting, if I am coasting I must be going down hill.