Sub PrintProperties_DAO()
'請引用 DAO 3.6
'在立即窗口打印所有屬性,遇到“有效性規(guī)則” 和“有效性文本”作提示
On Error Resume Next
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim fld As DAO.Field
Set db = CurrentDb()
Set tdf = db.TableDefs("表名")
Set fld = tdf.Fields("字段名")
Dim p As DAO.Property
For Each p In fld.Properties
Debug.Print p.Name & "-->" & p.Value
If p.Name = "ValidationRule" Then
Msgbox "有效性規(guī)則:" & p.Value
End If
If p.Name = "ValidationText" Then
Msgbox "有效性文本:" & p.Value
End If
Next
End Sub