Article View: comp.databases.ms-access
Article #323Re: How to Trap Oracle 7.3/ODBC Errors in Access 97?
From: jm
Date: Fri, 26 May 2000 00:00
Date: Fri, 26 May 2000 00:00
111 lines
5050 bytes
5050 bytes
C�sar, creo que lo que te ocurre es que no interceptas el error en el lugar
adecuado. Los mecanismos de gesti�n de errores de los procedimientos VBA
interceptan los errores producidos en el propio c�digo VBA. Pienso que los
errores que te interesan los intercepta el evento On Error del formulario.
Probablemente all� puedas colocar tu c�digo, con alguna modificaci�n. Si
miras la ayuda en el apartado "Evento Error", dice textualmente: "...Aqu� se
incluyen los errores del motor de base de datos Microsoft Jet, pero no los
errores en tiempo de ejecuci�n de Visual Basic..." y en definitiva el Jet
hace de intermediario con Oracle.
Juanjo
PD - Por la descripci�n que has dado del entorno en que trabajas (servidor
Oracle 7.3 en Unix y front-end Access con las tablas vinculadas mediante
ODBC) veo que coincidimos completamente en el escenario. Como somos muy
pocos, pienso que ser�a interesante iniciar una cierta colaboraci�n o
intercambio de experiencias mediante correo electr�nico (en el futuro
podemos pensar incluso en montar un grupo de noticias). Escr�beme para
cualquier cuesti�n a jmoreno@iccABC.es , quitando ABC de la direcci�n.
C�sar Arias Juan <carias@renfe.es> wrote in message
news:8givpo$hco$1@talia.mad.ttd.net...
(Excuse my english, please).
We have Oracle 7.3 in our Unix server (tables & views).
Clients run an Access 97 app (front-end & code).
Everything is fine except when a client tries to add a new register and the
primary key (unique) already exist. The Oracle constraint complains and my
app receives an error message through ODBC. Then Access 97 shows two error
message boxes:
1) the 1st one tells ODBC call failed.
2) the 2nd one has a ODBC error standard format:
[Microsoft][ODBC driver for Oracle][Oracle]ORA-00001: unique constraint
(<constraint name>) violated (#1)
I want to trap that kind of messages from inside my app and show meaningfull
messages to the final users. Something like "Error: that <key name> already
exist".
So, I've written an "On Error.." trapping procedure inside the form's
"Before_Update Event" (is there a better place?). For debugging propose,
I've set a flag and a alert message box that explains if the code logic
passes through the trapping routine, but it doesn't anytime.
Anyway, it doesn't work. This is that routine:
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo Trapping_Errors
Dim nError As Integer
Dim cError As String
Dim oError As Error
Dim bError As String
bError = "No errors" ' Flag
Bye_Sub:
MsgBox ("Ready to exit. " & bError) ' For debugging. Allways says "No
errors"!
Cancel = True 'Don't accept that operation
Exit Sub
Trapping_Errors:
bError = "ERRORS!" ' Flag. Never shown. But error ocurred!
nError = Err.Number
cError = Err.Description
' 1st try: "normal errors"
' Next message is NEVER shown
MsgBox ("Error Befor Updating: " & Trim(Str(nError)) & " " & cError)
' 2nd try: "normal & advanced errors"
' Next messages are NEVER shown
MsgBox ("# of Errors: " & Trim(Str(Errors.Count)))
For Each oError In DBEngine.Errors
MsgBox (oError.Description & Chr(13) & Chr(10) & oError.Source &
Chr(13) & Chr(10) & _
Str(oError.Number))
Next oError
Resume Bye_Sub
End Sub
' **** End of Code ****
Before exit, if I set Cancel = False, I'm accepting that erroneous operation
(wrong), my own messages are not shown. But Access shows that couple of ODBC
messages.
If I set Cancel = True, I'm not accepting that erroneous operation (right),
my own messages are not shown, ODBC errors are not shown. But the user is
locked in the current form's record (he can't move outside the current
record pushing tab or enter keys. He must push Escape to undo that
operation. That isn't bad but is not what I'm looking for).
SO, I NEED SOME HELP:
1) Any suggestion about that code?
2) Any file containing the list of that kind of errors (number &
description)?
Thanks
--
Saludos
C. Arias
Technical Details
Message-ID:
<8glh4i$qo5$1@pedraforca.cesca.es>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<8givpo$hco$1@talia.mad.ttd.net>Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII X-Google-Thread: 111a5a,7f0ec301d264a96b X-Google-Attributes: gid111a5a,public X-Google-Thread: f99a8,7f0ec301d264a96b X-Google-Attributes: gidf99a8,public X-Google-Thread: ff0ac,7f0ec301d264a96b X-Google-Attributes: gidff0ac,public X-Google-Thread: fcacf,7f0ec301d264a96b X-Google-Attributes: gidfcacf,public From: "jm" <jm@meet.com> Subject: Re: How to Trap Oracle 7.3/ODBC Errors in Access 97? Date: 2000/05/26 Message-ID: <8glh4i$qo5$1@pedraforca.cesca.es> X-Deja-AN: 627518107 Content-Transfer-Encoding: 8bit References: <8givpo$hco$1@talia.mad.ttd.net> Organization: CESCA News service. Catalunya X-MSMail-Priority: Normal X-Priority: 3 Content-Type: text/plain; charset=iso-8859-1 Mime-Version: 1.0 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211 Newsgroups: comp.databases.ms-access,comp.databases.oracle.misc,es.comp.bd.ms-access,microsoft.public.data.odbc