|
用下面的代码将表中的NULL值可以全部替换为0, 不过不理解为何要用LOOP?
个人理解,.MoveNext作用就是移动到下一条记录。(但是不加LOOP,只会对第一行起作用)
请高人指点下,非常感谢!
原帖链接:
http://www.office-cn.net/forum.p ... mp;page=1#pid732029
代码:
Sub test()
Dim res As ADODB.Recordset
Dim i As Integer
Set res = New ADODB.Recordset
res.Open "Data", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
res.MoveFirst
Do While Not res.EOF
With res
For i = 1 To 10
If IsNull(.Fields(i & "月")) Then
.Fields(i & "月") = 0
End If
Next i
.MoveNext
End With
Loop
End Sub
|
|