Find a table when you know the name of a column?

后端 未结 2 1580
攒了一身酷
攒了一身酷 2020-12-19 05:27

I have a DB in Access with an incredible amount of tables. Unfortunately, the creator used very non-descriptive names, so it\'s basically impossible to even guess what a tab

2条回答
  •  醉酒成梦
    2020-12-19 06:11

    This procedure will list the table name and column name for any columns whose names contain the text you supply. The results are printed in the Immediate window (go there with Ctrl+g)

    Public Sub ListTablesWithColumnNamesContaining(ByVal pText As String)
    Dim db As DAO.Database
    Dim tdf As DAO.TableDef
    Dim fld As DAO.Field
    Set db = CurrentDb
    For Each tdf In db.TableDefs
        For Each fld In tdf.Fields
            If InStr(1, fld.Name, pText, vbTextCompare) > 0 Then
                Debug.Print tdf.Name & ":", fld.Name
            End If
        Next fld
    Next tdf
    Set fld = Nothing
    Set tdf = Nothing
    Set db = Nothing
    End Sub
    

提交回复
热议问题