Sub test()
Dim db As DAO.Database
Dim rst As DAO.TableDef
Dim FIEL1 As DAO.Field
Dim prpLoop As Property
Set db = CurrentDb
Set rst = db.TableDefs("BB")
Set FIEL1 = rst.Fields("BB1")
SetProperty FIEL1, "CAPTION", "BB1的标题"
For Each prpLoop In FIEL1.Properties
Debug.Print " " & prpLoop.Name
Next prpLoop
End Sub
Sub SetProperty(dbsTemp As Object, strName As String, strValue As String)
Dim prpNew As Property
Dim errLoop As Error
On Error GoTo Err_Property
' 这是帮助中的写法 : dbsTemp.Properties("strName") = strValue,是错误的
dbsTemp.Properties(strName) = strValue
On Error GoTo 0
Exit Sub
Err_Property:
If DBEngine.Errors(0).Number = 3270 Then
Set prpNew = dbsTemp.CreateProperty(strName, dbText, strValue)
dbsTemp.Properties.Append prpNew
Resume Next
Else
For Each errLoop In DBEngine.Errors
MsgBox "Error number: " & errLoop.Number & vbCr & _
errLoop.Description
Next errLoop
End
End If
End Sub
' PASS PASS PASS
[此贴子已经被作者于2003-10-17 16:09:32编辑过]
|