null的使用无效

时间:2013-07-25 14:53:54

标签: ms-access-2007 access-vba

我希望这是我对这个数据库的最后一个问题。我写了一个代码:所有这些都是平均一组输入。

Public Sub CalcOverallRating()
Dim li_CalcValue As Integer

If IsNull((Forms![FRM_CSR]![PP1]!CBX_PP1.Value) Or _
           IsNull(Forms![FRM_CSR]![PP2]!CBX_PP2.Value) Or _
           IsNull(Forms![FRM_CSR]![PP3]!CBX_PP3.Value) Or _
           IsNull(Forms![FRM_CSR]![PP4]!CBX_PP4.Value) Or _
           IsNull(Forms![FRM_CSR]![PP5]!CBX_PP5.Value) Or _
           IsNull(Forms![FRM_CSR]![PP6]!CBX_PP6.Value) Or _
           IsNull(Forms![FRM_CSR]![PP7]!CBX_PP7.Value)) Then
    'Don't calculate if any values are null
Else
    li_CalcValue = (Forms![FRM_CSR]![PP1]!CBX_PP1.Value + _
                    Forms![FRM_CSR]![PP2]!CBX_PP2.Value + _
                    Forms![FRM_CSR]![PP3]!CBX_PP3.Value + _
                    Forms![FRM_CSR]![PP4]!CBX_PP4.Value + _
                    Forms![FRM_CSR]![PP5]!CBX_PP5.Value + _
                    Forms![FRM_CSR]![PP6]!CBX_PP6.Value + _
                    Forms![FRM_CSR]![PP7]!CBX_PP7.Value) / 7
    Forms![FRM_CSR].Text270.Value = li_CalcValue
    Forms![FRM_CSR].[Overall CSR].Value = li_CalcValue
End If

End Sub

另外,我在每个表格名称FRM_PP1到FRM_PP7中都有一个Call CalcOverallRating。

使用组合框时,会出现无效使用Null的错误。 请帮忙

1 个答案:

答案 0 :(得分:1)

您已在第一个IsNull()功能中包含所有条件。这些应该是分开的条件:

If IsNull(something) Or IsNull(somethingElse) ... Then

删除左括号和右括号。