不会改为默认值,但你需要手动更改,以免产生一些不必要的错误.
可以参考以下实例:
Private Sub 设置料件资料各新增字段的默认值()
Dim Ts As Workspace
Dim Db As Database
Dim Rs As DAO.Recordset
Dim fd As Field
Dim i As Long, j As Long
Set Ts = DBEngine.Workspaces(0)
Set Db = Ts.Databases(0)
Set Rs = Db.OpenRecordset("select * from 料件资料 order by id")
Ts.BeginTrans
j = Rs.Fields.Count - 1
Do Until Rs.EOF
For i = 0 To j
If IsNull(Rs.Fields(i).Value) And Rs.Fields(i).Required Then
Rs.Edit
Rs.Fields(i).Value = Rs.Fields(i).DefaultValue
Rs.Update
End If
Next i
Rs.MoveNext
Loop
Ts.CommitTrans
End Sub
[此贴子已经被作者于2003-2-13 13:06:16编辑过]
|