开发者

Get column names

开发者 https://www.devze.com 2023-01-08 20:46 出处:网络
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 to no avail

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 to no avail.


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


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

精彩评论

暂无评论...
验证码 换一张
取 消