Q:

How to check if a table exists in MS Access for vb macros

Possible Duplicate:
Check if access table exists 

I'm new to vba macros. Any idea how to check if a table exists or not?
I have searched for previous posts but did not get a clear solution for this.

A:

Setting a reference to the Microsoft Access 12.0 Object Library allows us to test if a table exists using DCount.
Public Function ifTableExists(tblName As String) As Boolean

    If DCount("[Name]", "MSysObjects", "[Name] = '" & tblName & "'") = 1 Then

        ifTableExists = True

    End If

End Function

A:

Exists = IsObject(CurrentDb.TableDefs(tablename))

A:

I know the question is already answered, but I find that the existing answers are not valid:
they will return True for linked tables with a non working back-end.
Using DCount can be much slower, but is more reliable.  
Function IsTable(sTblName As String) As Boolean
    'does table exists and work ?
    'note: finding the name in the TableDefs collection is not enough,
    '      since the backend might be invalid or missing

    On Error GoTo hell
    Dim x
    x = DCount("*", sTblName)
    IsTable = True
    Exit Function
hell:
    Debug.Print Now, sTblName, Err.Number, Err.Description
    IsTable = False

End Function

