Click to See Complete Forum and Search --> : error trapping Urgent


freek
August 19th, 1999, 04:06 AM
How can I examine an error code from ODBC and Oracle
using VBA?

if I use form_error, I can trap the error but dataerr gives me the code 7786 for different errors.

Greg85374
August 15th, 2005, 10:05 PM
Id you Lookup ODBC Errors youll Fin that there is an err code number block assigned to odbc.

Rather than using access form method try this:

Private sub MysubName

On Error Goto MySubNameErr


'You normal code goes in here

'eg..Test this by using didvision by 0

dim int1,int2 as integer
dim intAns as integer
int1 = 5
int2 = 0
intAns = int1/int2

Exit sub (or exit function for function)
Msgbox err.Number & "- " & vbcrlf & Err.Description,Vbinformation,"Error Trap Example"
Err.Clear
'then decide on Resume next or Exit Sub
'generally I exit sub so it doesnt have a chance to create more errors

End Sub