dbTalk Databases Forums  

Displaying ODBC errors (it's not happening)

comp.database.ms-access comp.database.ms-access


Discuss Displaying ODBC errors (it's not happening) in the comp.database.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
April
 
Posts: n/a

Default Displaying ODBC errors (it's not happening) - 02-05-2004 , 03:41 PM






Hi,

I have an Access97 db linked to Oracle 7.3.

I am inserting a record (or updating) to a linked table through a
recordset append, which which should return the trigger error message
from the server. However it only returns the message: 3155 - insert on
linked table X failed.

If I enter or update the record directly in the linked table the
trigger error message IS returned.

I have a function that loops through the Errors collection to report
all the ODBC errors that occur. In most cases it does report the
errors as it should. In this case it does not.

Any ideas? I really need to display the trigger errors!

here is the code run on the form Save:

Dim rs As Recordset
Dim fld As Field
Dim strsql As String
Dim smsg As String

If checkMandatoryFields(Me) = False Then
SetStatusMessage SMANDATORYFIELDFAIL, Forms.frmMain
Set rs = Nothing
Set fld = Nothing
Exit Sub
End If

With Me
Select Case pgdata.Properties.EditMode
Case EMADDNEW
If (MsgBox("Update all changes?", vbYesNo + vbQuestion) =
vbYes) Then
.UPDATED = Date
.UPDATED_BY = Nz(Left$(CurrentUser(), 12), "UNKNOWN")
Set rs = Me.RecordsetClone
With rs
.AddNew
For Each fld In rs.Fields
fld.Value = Me(fld.Name)
Next fld
.update
End With
smsg = SUPDATEMSG
Else
smsg = SCANCELMSG
End If
Case Else
If (MsgBox("Update all changes?", vbYesNo + vbQuestion) =
vbYes) Then
.UPDATED = Date
.UPDATED_BY = Nz(Left$(CurrentUser(), 12), "UNKNOWN")
.Dirty = False
smsg = SUPDATEMSG
Else
.Undo
smsg = SCANCELMSG
End If
End Select
End With

SetStatusMessage smsg, Forms.frmMain
Forms("frmMainSectMZimp").ResetForm

Set rs = Nothing
Set fld = Nothing
cmdCancel_Click

err_exit:
Exit Sub
err_handler:
Call ErrorHandler(Me.Name & " cmdSave_click:", Err.Number,
Err.DESCRIPTION, True)
Set rs = Nothing
Set fld = Nothing
Resume err_exit


Here is the Error handler:

Public Function ErrorHandler(rstrProc As String, rlngErr As Long,
rstrDesc As String, displaymsg As Boolean) As String
'Purpose: global error handler. manages the entire error collection
and returns the detailed ODBC errors

On Error GoTo err_handler

Dim db As Database
Dim rs As Recordset
Dim errJet As Error
Dim strDAOMsg As String
Dim strMsg As String
Dim gstrAppTitle As String


Notification True

Set db = CurrentDb
On Error Resume Next
gstrAppTitle = db.Properties("AppTitle")
Set db = Nothing

strMsg = "A Problem was Encountered with " & gstrAppTitle & "@@"
strMsg = strMsg & "Routine: " & rstrProc & vbCrLf & vbCrLf
strMsg = strMsg & "Message: " & rstrDesc & " [" & CStr(rlngErr) & "]"

' If Jet errors were found, add them to the message
If DBEngine.Errors.count > 1 Then
If DBEngine.Errors(DBEngine.Errors.count - 1).Number = rlngErr
Then
For Each errJet In DBEngine.Errors
With errJet
strDAOMsg = strDAOMsg & " " & .DESCRIPTION & " [" &
CStr(.Number) & " in " & .SOURCE & "]"
End With
Next
strMsg = strMsg & vbCrLf & vbCrLf & "Details:" & strDAOMsg
End If
Beep
If displaymsg Then MsgBox strMsg, vbOKOnly + vbCritical,
gstrAppTitle
Else
Beep
If displaymsg Then MsgBox strMsg, vbOKOnly + vbCritical,
gstrAppTitle
End If

ErrorHandler = strMsg
Notification False

err_exit:
On Error Resume Next
Exit Function

err_handler:
' In a failure, this routine should not call itself
Set db = Nothing
Beep
strMsg = "Problem@This application has encountered a problem '" &
Err.DESCRIPTION & " [" & CStr(Err.Number) & "]' in the Error Handler."
& "@"
MsgBox strMsg, vbOKOnly + vbCritical, gstrAppTitle
Resume err_exit

End Function


Thanks,
April

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.