Greetings.
I'm new to ADO and I'm trying to implement the following function which will determine if TName exists as a table. The function crashes in one of my database; works well in all others!! Does anyone have a clue/idea/comment to my problem? I've tried creating a new db and importing 'everything' to the new file - still crashes! I've re-written this code many times - still crashes!! i'm at my wit's end on this!!
Public Function isTable(TName As String) As Boolean
On Error Resume Next
'-------------------------------------------------------------------------------------------------
' Input: table Name
' Output: true if table exists, false if table does not exist
'-------------------------------------------------------------------------------------------------
Dim test As String
Dim cat As New ADOX.Catalog
Const NAME_NOT_IN_COLLECTION = 3265
cat.ActiveConnection = CurrentProject.Connection
test = cat.Tables(TName).Name
If Err.Number <> NAME_NOT_IN_COLLECTION Then
isTableQuery = True
Else
isTableQuery = False
End If
End Function
Thank you in advance.
- Lorentz
I'm new to ADO and I'm trying to implement the following function which will determine if TName exists as a table. The function crashes in one of my database; works well in all others!! Does anyone have a clue/idea/comment to my problem? I've tried creating a new db and importing 'everything' to the new file - still crashes! I've re-written this code many times - still crashes!! i'm at my wit's end on this!!
Public Function isTable(TName As String) As Boolean
On Error Resume Next
'-------------------------------------------------------------------------------------------------
' Input: table Name
' Output: true if table exists, false if table does not exist
'-------------------------------------------------------------------------------------------------
Dim test As String
Dim cat As New ADOX.Catalog
Const NAME_NOT_IN_COLLECTION = 3265
cat.ActiveConnection = CurrentProject.Connection
test = cat.Tables(TName).Name
If Err.Number <> NAME_NOT_IN_COLLECTION Then
isTableQuery = True
Else
isTableQuery = False
End If
End Function
Thank you in advance.
- Lorentz