使用控件更新空值



我试图创建一个控件(绑定到表中的字段),当您单击它时,值更新。当值不为空时,我的代码都很好,但是我需要控件(名为"ObjectivesMetrics")为用户提供更新值,即使底层字段值为空,以便值从空传递到值"未识别的指标"。我下面的代码工作良好,直到最后两行。我得到的错误信息是运行时间424 -对象必需

Private Sub Comando107_Click()
    If ObjectivesMetrics = ("metrics identified") Then
        ObjectivesMetrics = ("metrics agreed")
    ElseIf ObjectivesMetrics = ("metrics agreed") Then
        ObjectivesMetrics = ("metrics partially agreed")
    ElseIf ObjectivesMetrics = ("metrics partially agreed") Then
        ObjectivesMetrics = ("metrics not agreed")
    ElseIf ObjectivesMetrics = ("metrics not agreed") Then
        ObjectivesMetrics = ("metrics complete")
    ElseIf ObjectivesMetrics = ("metrics complete") Then
        ObjectivesMetrics = ("metrics not yet identified")
    ElseIf ObjectivesMetrics = ("metrics not yet identified") Then
        ObjectivesMetrics = ("metrics identified")
    ElseIf ObjectivesMetrics Is Null Then
        ObjectivesMetrics = ("metrics not yet identified")

End If

先测试null。

Private Sub Comando107_Click()
    If IsNull(ObjectivesMetrics) Then
        ObjectivesMetrics = ("metrics not yet identified")
    ElseIf ObjectivesMetrics = ("metrics identified") Then
        ObjectivesMetrics = ("metrics agreed")
    ElseIf ObjectivesMetrics = ("metrics agreed") Then
        ObjectivesMetrics = ("metrics partially agreed")
    ElseIf ObjectivesMetrics = ("metrics partially agreed") Then
        ObjectivesMetrics = ("metrics not agreed")
    ElseIf ObjectivesMetrics = ("metrics not agreed") Then
        ObjectivesMetrics = ("metrics complete")
    ElseIf ObjectivesMetrics = ("metrics complete") Then
        ObjectivesMetrics = ("metrics not yet identified")
    Else
        ObjectivesMetrics = ("metrics identified")
    End If
End If

最新更新