如果那么Else Statement Access 2010

时间:2013-11-30 17:47:00

标签: ms-access if-statement access-vba

我一直在寻找答案的论坛,我似乎找不到答案。对不起代码的长度!

基本上,如果第一个“if”语句没有返回任何内容,我想要做的是在“Billing_Prepayment”字段中设置“$ 0.00”的值。目前,如果我运行代码并且没有匹配项,则“Billing_Prepayment”字段将变为空白。不确定我错过了什么。我试过了; “”,Null,Isblank。没有任何效果。

   Private Sub AccountID_Change()
    ' Adds prepaid values to invoice
      If DLookup("Total_Prepayment", "quePrepayment", "[AccountID] = Forms![frmInvoices]!AccountID And [Billing_Month] = Forms![frmInvoices]!Billing_Month And [Billing_Year] = Forms![frmInvoices]!Billing_Year") = Null Then
        Billing_Prepayment = "$0.00"
      Else
        Billing_Prepayment = DLookup("Total_Prepayment", "quePrepayment", "[AccountID] = Forms![frmInvoices]!AccountID And [Billing_Month] = Forms![frmInvoices]!Billing_Month And [Billing_Year] = Forms![frmInvoices]!Billing_Year")
End If      
End Sub

1 个答案:

答案 0 :(得分:1)

  If (DLookup("Total_Prepayment", "quePrepayment", "[AccountID] = Forms![frmInvoices]!AccountID And [Billing_Month] = Forms![frmInvoices]!Billing_Month And [Billing_Year] = Forms![frmInvoices]!Billing_Year") & "") = ""