A
Allen_N
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?
&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?