if isnull(Rst.Fields("z(" & h & ")")) or isnull(Rst.Fields("j(" & h & ")")) then
VB QQ群:47715789
再次重新上传,
我把这MDB的J()字段给改过来了!设置为数字型,并且其默认值是否设置为0呢?否则,当第某记录上的J()为空的话,系统默认其为数字0,这样一来,计算不会受阻呢?
Private Sub Command2_Click()
Dim a
Dim i, h As Single
If IsNull(Rst.Fields("z(" & h & ")")) Or IsNull(Rst.Fields("j(" & h & ")")) Then
For i = 1 To Rst.RecordCount
For h = 1 To 9
If Rst.Fields("z(h)").Value = "银行存款" Then
a = a + Val(Rst.Fields("j(h)").Value)
Next h
Rst.MoveNext
Text3.Text = Val(a)
End If
Next i
conn.Close
End If
End Sub
Dim a
Dim i, h As Integer
If Not Rst.EOF() Then
For i = 1 To Rst.RecordCount
For h = 1 To 9
If Rst.Fields("z(" & h & ")").Value = "银行存款" Then
a = a + Val(Rst.Fields("j(" & h & ")").Value)
End If
Next h
Rst.MoveNext
Next i
Text4.Text = Val(a)
End If
End Sub
执行时出现: 无效使用NULL!
黄条指示在:a = a + Val(Rst.Fields("j(" & h & ")").Value)