Get column names

前端 未结 2 1422
终归单人心
终归单人心 2020-12-05 15:52

I need to get all of the column names of a table using VBA or Access SQL and iterate through them for validation, does anyone have a solution to this, I have searched Google

相关标签:
2条回答
  • 2020-12-05 16:02

    This will work

    Set db = CurrentDb()
    Set rs1 = db.OpenRecordset("Table1")
    Dim fld As DAO.Field
    For Each fld In rs1.Fields
        MsgBox (fld.Name)
    Next
    Set fld = Nothing
    
    0 讨论(0)
  • 2020-12-05 16:04
    Dim l As Integer
    
    For l = 0 To CurrentDb.TableDefs("tbl_Name").Fields.Count - 1
      Debug.Print CurrentDb.TableDefs("tbl_Name").Fields(l).name
    Next l
    
    0 讨论(0)
提交回复
热议问题