Office中国论坛/Access中国论坛

标题: [求助][已解决]如何获取一个表的列数呀? [打印本页]

作者: jacken    时间: 2006-5-15 23:30
标题: [求助][已解决]如何获取一个表的列数呀?
请教大侠,如何获取一个ACCESS表有多少列呀。并且获取列值!谢谢

[此贴子已经被LucasLynn于2006-5-15 16:43:46编辑过]


作者: Benjamin_luk    时间: 2006-5-15 23:38
Function GetFieldCount()
Dim rs1 As Recordset
Set rs1 = CurrentDb.OpenRecordset("SELECT * FROM myTable")
msgbox rs1.Fields.Count
set rs1=nothing
End function
作者: Benjamin_luk    时间: 2006-5-15 23:51
Function GetFieldCount()
Dim rs1 As Recordset, I As Integer
Set rs1 = CurrentDb.OpenRecordset("SELECT * FROM myTable")
MsgBox rs1.Fields.Count '  列
For I = 0 To rs1.Fields.Count - 1
MsgBox rs1.Fields(I).Name '名称  
Next I
Set rs1 = Nothing
End Function


不知是否是你想要的。[em01]
作者: jacken    时间: 2006-5-16 00:32
太好了,就是我需要的东西。谢谢了哦




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3