I have a bizarre problem with an error handler. I set it up to trap error
&H80040E14 (-2147217900), which occurs when the routine tries to create a
view that already exists. The code is:
Public Function CreateOrReplaceView(strView As String, strSQL As String)
' N.B. Must refresh database window (F5) to see new 'view' object.
Dim flag
Dim lngErrNo As Long, strErrMsg As String
flag = 0
On Error GoTo Err_CreateOrReplaceView
CurrentProject.Connection.Execute _
"CREATE VIEW " & strView & " AS " & strSQL
' "CREATE VIEW TestView AS SELECT DISTINCT ITEM_NUMBER FROM
STG_PRODUCT"
On Error GoTo 0
Exit Function
Err_CreateOrReplaceView:
lngErrNo = Err.Number
strErrMsg = Err.Description
Select Case lngErrNo
Case -2147217900 ' &H80040E14
CurrentProject.Connection.Execute _
"DROP VIEW " & strView
Resume
Case Else
Call MsgBox("Error" & Str(lngErrNo) & ": " & strErrMsg, _
vbExclamation, "CreateOrReplaceView()")
flag = lngErrNo
Stop
Resume Next
End Select
End Function
And here is the result (in the Debug Window) when the error handler is
entered as a result of assigning a bad SELECT statement (which contained
"TRIM" instead of "RTRIM") to the variable strSQL:
?lngErrNo
-2147217900
?strErrMsg
'Trim' is not a recognized function name.
So, it appears as though the same error number is associated with 2 (at
least) different error conditions, which sounds nuts to me.
Any ideas?
Roger Carlson - 08 Nov 2006 15:05 GMT
Make sure none of your References are Missing. Sometimes when a reference is
missing, you will get an erroneous error message.

Signature
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
> I have a bizarre problem with an error handler. I set it up to trap error
> &H80040E14 (-2147217900), which occurs when the routine tries to create a
[quoted text clipped - 51 lines]
>
> Any ideas?
Allen_N - 09 Nov 2006 01:53 GMT
Thanks, Roger.
I think you're on the money: I was actually missing a table that my code was
trying to query.
> Make sure none of your References are Missing. Sometimes when a reference is
> missing, you will get an erroneous error message.
[quoted text clipped - 55 lines]
> >
> > Any ideas?