标题:[求助]得到数据库中所有表的字段!
取消只看楼主
zeyidao
Rank: 1
等 级:新手上路
帖 子:28
专家分:0
注 册:2007-9-17
 问题点数:0 回复次数:0 
[求助]得到数据库中所有表的字段!

Sub TableInfo()
 Dim i, j As Integer, Fname As String
 Dim db1 As Database, Td1 As TableDefs
 Dim fld1 As Fields
 Dim FieldNum, RecNum As Integer

 Fname$ = "d:\mdb\xx.mdb" ‘XX为ACCESS数据库文件
 Set db1 = OpenDataBase(Fname$) '打开一数据库文件
 Set Td1 = db1.TableDefs
 For i = 1 To Td1.Count - 1
  Debug.Print Td1(i).Name ‘输出表名
  Set fld1 = Td1(i).Fields '出错!!!!
  FieldNum = fld1.Count
  RecNum = Td1(i).RecordCount
  Debug.Print "当前表共有"; FieldNum; "个字段" ‘输出字段的个数
  Debug.Print "当前表有:"; RecNum; "记录" ‘输出记录的个数
  For j = 0 To fld1.Count - 1
   Debug.Print "字段名", fld1(j).Name ‘输出字段名
   Debug.Print "类型", fld1(j).Type ‘输出字段类型
  Next j
 Next i
End Sub

请高手指教一下

搜索更多相关主题的帖子: 数据库 字段 Set Dim Fname 
2007-10-12 15:32



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-177054-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.200386 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved