我正在尝试创建一个控件(绑定到表中的字段),当您单击它时,值会更新。当值不为null时,我的代码一切都很好但是我需要控件(名为'ObjectivesMetrics')来提供用户更新值,即使基础字段值为null,以便值从null传递给值“未确定的指标“。我的下面的代码工作正常,直到最后两行。我得到的错误消息是运行时间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
答案 0 :(得分:1)
首先测试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