问题描述
您好,
我如何在已知的表格中找到优质密钥?
Access 97帮助文档似乎建议它这与索引相关,
所以,它有点像
tbldef.Indexes(0).Index(0).Primary
....
非常感谢提前。
Don
Hello,
How could I find the primery key(s) if any in a known table?
Access 97 help doc seems to suggest it''s tied to Index,
so, it''s sort of along the line of
tbldef.Indexes(0).Index(0).Primary
....
Many thank in advance.
Don
推荐答案
Dim tdf作为DAO.TableDef
Dim fld作为DAO.Field
Dim idx作为DAO.index
使用CurrentDb
设置tdf = .TableDefs(sTableName)
每个idx in tdf.Indexes
如果idx.Primary = True那么
Debug.Print idx.Name
for each fld in idx.Fields
Debug.Print" " ;; fld.Name
下一页
结束如果
下一页
结束
''清理
Dim tdf As DAO.TableDef
Dim fld As DAO.Field
Dim idx As DAO.index
With CurrentDb
Set tdf = .TableDefs(sTableName)
For Each idx In tdf.Indexes
If idx.Primary = True Then
Debug.Print idx.Name
For Each fld In idx.Fields
Debug.Print " ";fld.Name
Next
End If
Next
End With
''cleanup
这篇关于找到Primery Key的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!