468,554 Members | 1,896 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,554 developers. It's quick & easy.

trap odbc errors

Hi!

I have to use MS-Access2000 as a frontend for an oracle database. And
I dont want to see these ORA-xxxx Popups if an error occures.
So I use something like the following in access (it should work with
sql-server....):

Private Sub Form_Error(DataErr As Integer, Response As Integer)
Dim errX As DAO.Error

If Errors.Count > 1 Then
For Each errX In DAO.Errors
Debug.Print "ODBC Error"
Debug.Print errX.Number
Debug.Print errX.Description
Next errX
end if
End Sub

But I always get Errors.Count=0 :-(
Oracle is version 9.

What is wrong ?
What can I do, to get the oracle-error-number - or better the full
error-description from the popup?
Thanks,
Detlev
Nov 12 '05 #1
3 3594
The universal solution is a real pain, and making the solution work in Access
2000 is a bigger pain because the example code from Microsoft will not behave
right without significant tweaking. Access 97 and 2002 handle it much better.

Basically, what you have to do is trap the BeforeUpdate and Delete events on
the form, grap the data from the bound controls on the form, then perform the
Add, Update, or Delete on the form's RecordsetClone, and Cancel the original
action. Since the recordset action happens in VB code, you can do normal
error trapping to get the error details.

Now, that said, there's a simpler solution - don't allow any add/edit/delete
through a bound form. Use unbound forms instead. This is a paid too, though,
because that means no editing in continuous forms, and that includes
continuous subforms. I suppose you could have continuous forms bound to local
temporary data tables, and copy data back and forth to the server. You'd need
to copy data to the temp data table when it's time to display it in the
subform, and either post changes back to the server after each row update or
use a sequence of of a delete, update, and insert query to post changes back
to the server as a batch. The pain here is that you need to implement your
own Optimistic or Batch Optimistic locking scheme.

On 13 May 2004 07:04:31 -0700, da*******@web.de (Detlev Ahlgrimm) wrote:
Hi!

I have to use MS-Access2000 as a frontend for an oracle database. And
I dont want to see these ORA-xxxx Popups if an error occures.
So I use something like the following in access (it should work with
sql-server....):

Private Sub Form_Error(DataErr As Integer, Response As Integer)
Dim errX As DAO.Error

If Errors.Count > 1 Then
For Each errX In DAO.Errors
Debug.Print "ODBC Error"
Debug.Print errX.Number
Debug.Print errX.Description
Next errX
end if
End Sub

But I always get Errors.Count=0 :-(
Oracle is version 9.

What is wrong ?
What can I do, to get the oracle-error-number - or better the full
error-description from the popup?
Thanks,
Detlev


Nov 12 '05 #2
Detlev Ahlgrimm wrote:
Hi!

I have to use MS-Access2000 as a frontend for an oracle database. And
I dont want to see these ORA-xxxx Popups if an error occures.
So I use something like the following in access (it should work with
sql-server....):

Private Sub Form_Error(DataErr As Integer, Response As Integer)
Dim errX As DAO.Error

If Errors.Count > 1 Then
For Each errX In DAO.Errors
Debug.Print "ODBC Error"
Debug.Print errX.Number
Debug.Print errX.Description
Next errX
end if
End Sub

But I always get Errors.Count=0 :-(
Oracle is version 9.

What is wrong ?
What can I do, to get the oracle-error-number - or better the full
error-description from the popup?


Loop the DBEngine.Errors collection.

--
Error reading sig - A)bort R)etry I)nfluence with large hammer
Nov 12 '05 #3
On Thu, 13 May 2004 18:25:53 +0100, Trevor Best <nospam@localhost> wrote:
Detlev Ahlgrimm wrote:
Hi!

I have to use MS-Access2000 as a frontend for an oracle database. And
I dont want to see these ORA-xxxx Popups if an error occures.
So I use something like the following in access (it should work with
sql-server....):

Private Sub Form_Error(DataErr As Integer, Response As Integer)
Dim errX As DAO.Error

If Errors.Count > 1 Then
For Each errX In DAO.Errors
Debug.Print "ODBC Error"
Debug.Print errX.Number
Debug.Print errX.Description
Next errX
end if
End Sub

But I always get Errors.Count=0 :-(
Oracle is version 9.

What is wrong ?
What can I do, to get the oracle-error-number - or better the full
error-description from the popup?


Loop the DBEngine.Errors collection.


The Errors collection is an alias to DBEngine.Errors, and neither one turns
out to work for getting ODBC errors in a Form's Error event handler.
Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Steve | last post: by
3 posts views Thread by Eitan | last post: by
3 posts views Thread by Jason Gyetko | last post: by
7 posts views Thread by tina | last post: by
4 posts views Thread by Phil Latio | last post: by
2 posts views Thread by ramu | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.