UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Error Descriptions Not Matching Up, Access 2013    
 
   
DanielPineault
post Jan 16 2017, 02:10 PM
Post#1


UtterAccess VIP
Posts: 5,154
Joined: 30-June 11



For testing purpose I created a very simple function

CODE
Sub RaiseError(lErrNumber As Long)
    On Error GoTo Error_Handler

    Err.Raise lErrNumber

Error_Handler_Exit:
    On Error Resume Next
    Exit Sub

Error_Handler:
    MsgBox "The following error has occured" & vbCrLf & vbCrLf & _
           "Error Number: " & Err.Number & vbCrLf & _
           "Error Source: RaiseError" & vbCrLf & _
           "Error Description: " & Err.Description & _
           Switch(Erl = 0, "", Erl <> 0, vbCrLf & "Line No: " & Erl) _
           , vbOKOnly + vbCritical, "An Error has Occured!"
    Resume Error_Handler_Exit
End Sub


What I am finding odd, and I'm hoping someone can explain is why the Err.Descriptions are not matching up, in many cases, with what a user gets at runtime for the same error number.

For instance, If we raise Error 2501 (classic error) I get returned:

Error Number: 2501
Error Source: RaiseError
Error Description: Application-defined or object-defined error


Yet I'd expect to get

Error Number: 2501
Error Source: RaiseError
Error Description: The | action was canceled.You used a method of the DoCmd object to carry out an action in Visual Basic, but then clicked Cancel in a dialog box. For example, you used the Close method to close a changed form, then clicked Cancel in the dialog box that asks if you want to save the changes you made to the form



Another example, Error 3046 I get returned

Error Number: 3046
Error Source: RaiseError
Error Description: Application-defined or object-defined error


Yet I'd expect to get

Error Number: 3046
Error Source: RaiseError
Error Description: Could not save; currently locked by another user.



So why does raising an error not return the description users will see and is there a way to make it so? Right now as it stands, almost everything is coming up as 'Application-defined or object-defined error'.

--------------------
Daniel Pineault (2010-2017 Microsoft MVP)
Professional Help: http://www.cardaconsultants.com
Free MS Access Code, Tips, Tricks and Samples: http://www.devhut.net

* Design should never say "Look at me". It should always say "Look at this". -- David Craib
* A user interface is like a joke, if you have to explain it, it's not that good! -- Martin LeBlanc


All code samples, demonstration databases, links,... are provided 'AS IS' and are to be used at your own risk! Take the necessary steps to check, validate ...
Go to the top of the page
 
Doug Steele
post Jan 16 2017, 04:18 PM
Post#2


UtterAccess VIP
Posts: 21,313
Joined: 8-January 07
From: St. Catharines, ON (Canada)


Daniel: This sounds identical to the issue I mentioned a couple of days ago, where I was getting "Application-defined or object-defined error" for error 2465, when AccessError(2465) returns
QUOTE
Microsoft Access can't find the field '|1' referred to in your expression.@You may have misspelled the field name, or the field may have been renamed or deleted.@@1@1@11730@1

My only guess is that using the Raise method of the Err object doesn't get handled the way a "true" error does.

What were you hoping to accomplish with your test?

--------------------
Go to the top of the page
 
JForbes
post Jan 16 2017, 04:25 PM
Post#3



Posts: 32
Joined: 11-November 16
From: Indianapolis, IN


I think this is what you are asking about: Application-defined or object-defined error

With the err.Raise, you can supply the Description if you want:
Sub Raise(Number As Long, [Source], [Description], [HelpFile], [HelpContext])
Go to the top of the page
 
DanielPineault
post Jan 16 2017, 04:36 PM
Post#4


UtterAccess VIP
Posts: 5,154
Joined: 30-June 11



Just a quick way to reproduce error message was all. Nothing critical. I'll just turn to the Error table that I have from God know when. Just thought a simple function in my library would facilitate things. Not a big deal. I just find it odd and thought there might be something I was missing.

QUOTE
Daniel: This sounds identical to the issue I mentioned a couple of days ago, where I was getting "Application-defined or object-defined error" for error 2465, when AccessError(2465) returns

It does indeed.

--------------------
Daniel Pineault (2010-2017 Microsoft MVP)
Professional Help: http://www.cardaconsultants.com
Free MS Access Code, Tips, Tricks and Samples: http://www.devhut.net

* Design should never say "Look at me". It should always say "Look at this". -- David Craib
* A user interface is like a joke, if you have to explain it, it's not that good! -- Martin LeBlanc


All code samples, demonstration databases, links,... are provided 'AS IS' and are to be used at your own risk! Take the necessary steps to check, validate ...
Go to the top of the page
 
DanielPineault
post Jan 16 2017, 04:37 PM
Post#5


UtterAccess VIP
Posts: 5,154
Joined: 30-June 11



The point here was to raise an Error and be able to get the Description that end-users get displayed. Just a testing and validation tool. Nothing critical.

--------------------
Daniel Pineault (2010-2017 Microsoft MVP)
Professional Help: http://www.cardaconsultants.com
Free MS Access Code, Tips, Tricks and Samples: http://www.devhut.net

* Design should never say "Look at me". It should always say "Look at this". -- David Craib
* A user interface is like a joke, if you have to explain it, it's not that good! -- Martin LeBlanc


All code samples, demonstration databases, links,... are provided 'AS IS' and are to be used at your own risk! Take the necessary steps to check, validate ...
Go to the top of the page
 
gemmathehusky
post Jan 18 2017, 12:36 PM
Post#6


UtterAccess VIP
Posts: 4,401
Joined: 5-June 07
From: UK


2501 is perhaps a bad example to use?

you will know more than me, but 2501 is a generic "failed to run" event isn't it.

Form or Report didn't open because the query was "bad" = 2501
Cancel a docmd.openquery (action query) = 2501


can you raise an existing error, or does raiseerror have to use a "new" error number.


this https://msdn.microsoft.com/en-us/library/of...office.11).aspx

explains this

QUOTE
In summary, Visual Basic searches back up the calls list for an enabled error handler if:
•An error occurs in a procedure that doesn't include an enabled error handler.
•An error occurs within an active error handler. If you use the Raise method of the Err object to raise an error, you can force Visual Basic to search backward through the calls list for an enabled error handler.


is this what you are seeing, maybe?

--------------------
Dave (Male)

(Gemma was my dog)
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    23rd September 2017 - 06:29 PM