标题属性往往能直接显示该字段的具体含义。所以如何通过表字段去获取该字段的标题呢?如表“表1”中,或者字段“toolname”的标题名“工具”
利用DAO自定义一个获取字段标题的函数。
Public Function GetfldCaption(tblName As String, fldName As String)
On Error Resume Next
Dim rs As DAO.Recordset
Set rs = CurrentDb().OpenRecordset(tblName)
GetfldCaption = rs(fldName).Properties("Caption")
rs.Close
Set rs = Nothing
End Function
窗体调用该函数
Me.Label0.Caption = "表1的字段“toolname”的标题名是 " & GetfldCaption("表1", "toolname")