Checking for Existence of Tables : Table Properties « Access « VBA / Excel / Access / Word






Checking for Existence of Tables

 
Function TableExists(WhichTable)
    Dim cnn As ADODB.Connection
    Dim rst As ADODB.Recordset
    Dim fld As ADODB.Field
    TableExists = False

    MyConn = "C:\t.mdb"

    Set cnn = New ADODB.Connection

    With cnn
        .Provider = "Microsoft.Jet.OLEDB.4.0"
        .Open MyConn
    End With

    Set rst = cnn.OpenSchema(adSchemaTables)

    Do Until rst.EOF
        If LCase(rst!Table_Name) = LCase(WhichTable) Then
            TableExists = True
            GoTo ExitMe
        End If
        rst.MoveNext
    Loop

ExitMe:
    rst.Close
    Set rst = Nothing
    cnn.Close

End Function

 








Related examples in the same category

1.List table types
2.Listing Table Properties
3.Check table definition
4.Get Table documents
5.Table documents