'将指定表中的NULL值转换为零
Public Sub NullTo0(strSQL As String )
'strSQL为可读写的SELECT语句,所有字段必须为数值型
Dim Rst As Recordset
Dim strSQL As String
Dim lngFields As Long
Dim lngFidCount As Long
Set dbs = CurrentDb
Set Rst = dbs.OpenRecordset(strSQL)
lngFields = Rst.Fields.Count
Rst.MoveFirst
Do Until Rst.EOF
For lngFidCount = 1 To lngFields - 1
If IsNull(Rst.Fields(lngFidCount)) Then
Rst.Edit
Rst.Fields(lngFidCount) = 0
Rst.Update
End If
Next lngFidCount
Rst.MoveNext
Loop
End Sub