Ms access access中的If语句

Ms access access中的If语句,ms-access,if-statement,vba,Ms Access,If Statement,Vba,如果有人帮我把这些if语句放到if-else中,请检查if语句的动作。这是一个表单名“payment”,在继续付款之前,我需要确保这些文本框中没有一个是空的或空的……请帮助您的意思是如下所示吗?: If IsNull(CusID) Or IsNull(Me.CusID) Then Beep MsgBox "Specify a Customer or enter CustomerID to proceed", vbCritical CusID.SetFocus End If

如果有人帮我把这些if语句放到if-else中,请检查if语句的动作。这是一个表单名“payment”,在继续付款之前,我需要确保这些文本框中没有一个是空的或空的……请帮助

您的意思是如下所示吗?:

If IsNull(CusID) Or IsNull(Me.CusID) Then
    Beep
    MsgBox "Specify a Customer or enter CustomerID to proceed", vbCritical
    CusID.SetFocus
End If

If IsNull(paymenttype) Or IsNull(Me.paymenttype) Then
    Beep
    MsgBox "Please specify payment type", vbCritical
    paymenttype.SetFocus
End If

If IsNull(payment) Or IsNull(Me.payment) Then
    Beep
    MsgBox "Please enter any amount to proceed payment.", vbCritical
    payment.SetFocus
End If

我只是在“If”之前加了“Else”

你可能想加上你正在编码的语言的名称..你可能不想这样做。正如您所写的,每次都将验证每个字段。如果使用
ElseIf
,则如果
CusID
为空,则在下次运行代码之前不会验证其他字段。(假设在此之前CusId已更正。)我想这取决于你认为更好的用户体验是什么。谢谢你RubberDuck和stefan…没有你的帮助,我将无法纠正…我希望你以后在任何事情上再次帮助…编辑你的代码,因为有语法错误。如果不是别的,我犯了个错误。谢谢你的批改!我的荣幸!无论如何,如果你的问题解决了,我建议你结束这个问题:)
If IsNull(CusID) Or IsNull(Me.CusID) Then
  Beep
  MsgBox "Specify a Customer or enter CustomerID to proceed", vbCritical
  CusID.SetFocus

ElseIf IsNull(paymenttype) Or IsNull(Me.paymenttype) Then
  Beep
  MsgBox "Please specify payment type", vbCritical
  paymenttype.SetFocus

ElseIf IsNull(payment) Or IsNull(Me.payment) Then
  Beep
  MsgBox "Please enter any amount to proceed payment.", vbCritical
  payment.SetFocus

End If