How Can I Access Err.Description Inside the Form_Error Event? (1 Viewer)

whdyck

Registered User.
Local time
Yesterday, 23:45
Joined
Aug 8, 2011
Messages
169
Probably a bonehead question . . .

I'm trying to extract information from Err.Description within a form's Error event. Alas, Err.Description does not seem to be available from there.

I have a form that normally displays in DataSheet view. If a trigger on the Oracle back-end raises an error, I want my Access app to be able to parse out Err.Description and deliver a more user-friendly message than ODBC's message. I want to get the info about the message from the error coming back from Oracle, not by matching up error codes.

If I change the form to Single-Form view and put a Save button on it, I can capture Err.Description in the command button's Clicked() event, and then parse out what I need.

So if I must display this form in Datasheet view, where can I trap the ODBC error and display my user-friendly message?

Thanks!

Wayne
 

MarkK

bit cruncher
Local time
Yesterday, 21:45
Joined
Mar 17, 2004
Messages
8,180
Try the Error() function . . .
Code:
Private Sub Form_Error(DataErr As Integer, Response As Integer)
   MsgBox "Err.Description is: " & Error(DataErr)
End Sub
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 05:45
Joined
Sep 12, 2006
Messages
15,651
I thought it was accesserror


Code:
Private Sub Form_Error(DataErr As Integer, Response As Integer)
   MsgBox "Err.Description is: " & AccessError(DataErr)
   response = acdataerrcontinue  'usually
End Sub

testing does give a difference.

eg

?error(2501)
?accesserror(2501)
 

MarkK

bit cruncher
Local time
Yesterday, 21:45
Joined
Mar 17, 2004
Messages
8,180
Dave's right. AccessError() is better.
 

whdyck

Registered User.
Local time
Yesterday, 23:45
Joined
Aug 8, 2011
Messages
169
I thought it was accesserror


Code:
Private Sub Form_Error(DataErr As Integer, Response As Integer)
   MsgBox "Err.Description is: " & AccessError(DataErr)
   response = acdataerrcontinue  'usually
End Sub

testing does give a difference.

eg

?error(2501)
?accesserror(2501)

Thanks for pointing out AccessError. Unfortunately, I still don't get everything that Oracle is sending. When I just allow the ODBC error to display, it looks like this:

ODBC--update on a linked table 'otblInvRtsPeriod' failed.
[Oracle][ODBC][Ora]ORA-20004: Error: The new/modified record overlaps a Period with the following Description:
2012/2013
ORA-06512: at "USRINV.TRG_TBLINVRTSPERIOD", line 93
ORA-04088: error during execution of trigger 'USRINV.TRG_TBLINVRTSPERIOD'
(#20004)

However, when I print AccessError(DataErr), I see this:
ODBC--update on a linked table '|' failed.

I posted this question on UtterAccess, where BananaRepublic predicted precisely that result:
http://www.utteraccess.com/forum/Capture-Errdescriptio-t2007304.html

As per his other suggestions, I'm looking into using something like SHOW ERRORS in Oracle.

Here's another post I found that suggests a pass-thru query as the RecordSource might get me the Oracle errors:
http://www.access-programmers.co.uk/forums/showthread.php?t=220309

Thanks.

Wayne
 

Users who are viewing this thread

Top Bottom