i cannot figure out why the RS is not recognized in the catch area.
code:
please try to help

Public Function IsDataExist(ByVal Table As String, ByVal Field As String, ByVal value As String, Optional ByVal Operand As String = " = ") As Boolean
Try
Dim RS As New ADODB.Recordset()

RS.Open("SELECT COUNT(" & Field & ") AS CNT FROM " & Table & " WHERE " & Field & Operand & value, ConCourses, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockReadOnly)

IsDataExist = CBool(Val(RS("CNT")) & "")

If RS.State Then RS.Close()
RS = Nothing
Exit_Function:
Exit Function

Catch
MessageBox.Show("IsDataExist" & vbNewLine & Err.Description & vbNewLine & "FROM " & Table & " WHERE " & Field & Operand & value & vbNewLine & Err.Number)
If RS.State Then RS.Close()
RS = Nothing
IsDataExist = False
End Try
End Function