SQL 获取列名
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3343922/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 06:57:29 来源:igfitidea点击:
Get column names
提问by Matt
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.
我需要使用 VBA 或 Access SQL 获取表的所有列名并遍历它们进行验证,有没有人有解决方案,我已经搜索过谷歌无济于事。
回答by Fergal Moran
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
回答by Jose
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