访问条件必填字段

时间:2015-08-11 15:33:44

标签: vba ms-access access-vba

我正在创建一个表单,允许用户输入给定类别的分数1-5。在此示例中,On_Time_Payment)。对于每个类别,得分为3或更低必须在注释字段中进行解释(在本例中为On_Time_Payment_Comments)。我试图写一些东西,如果On_Time_Payment的值低于4,将迫使用户输入内容;但是,我现在所拥有的是允许任何分数在评论字段中没有任何内容传递。

   Private Sub On_Time_Payment_Comments_Exit(Cancel As Integer)
    If On_Time_Payment.Value < 4 Then
        If Len(On_Time_Payment_Comments) > 0 Then
        End If
        Else
            MsgBox "The value you entered for On Time Payment is 3 or less."
            Cancel = True
            On_Time_Payment_Comments.SetFocus
    End If
End Sub

非常感谢任何帮助!

3 个答案:

答案 0 :(得分:0)

<configuration>
  <source>${project.build.directory}/**/*.jtl</source>
  <targetDirectory>${project.build.directory}/jmeter/test_report</targetDirectory>
  <processAllFilesFound>true</processAllFilesFound>
</configuration>

答案 1 :(得分:0)

您的原始答案与您所需的相对接近,但我认为您已经忘记了If-Else-End If结构。这就是我想你想要的:

`Private Sub On_Time_Payment_Comments_Exit(Cancel As Integer)

    If On_Time_Payment.Value < 4 Then

        If (Len(On_Time_Payment_Comments) <= 0 Or IsNull(On_Time_Payment_Comments)) Then
            MsgBox "The value you entered for On Time Payment is 3 or less."
            Cancel = True
            On_Time_Payment_Comments.SetFocus
        End If

    End If

End Sub

`

答案 2 :(得分:0)

事实证明,表格上的字段与文本框的命名和属性有关。现在正在运作:

Private Sub On_Time_Payment_Comments_Exit(Cancel As Integer)
   If On_Time_Payment.Value < 4 Then
    If IsNull(On_Time_Payment_Comments) Then
        MsgBox "The score you entered for On Time Payment is less than 4. Please provide an explaination in the comment field."
        Cancel = True
        On_Time_Payment_Comments.SetFocus
    End If
  End If
End Sub

谢谢大家的帮助!