如果2个计算字段都为零,如何在Access 2003中禁止节?

时间:2016-04-26 18:50:05

标签: ms-access report

  • Windows 7上的Access 2003

enter image description here

我有一份按销售人员和客户分组的报告。在客户组页脚中,我显示客户名称,2015年第一季度的销售额(计算字段)和2016年第一季度的销售额(计算字段)。 2个计算字段称为txtQ1a和txt Q1b。

如果txtQ1a和txtQ1b都为空或零,我想隐藏该客户。这是我尝试过的,虽然现在已经注释掉了。

Private Sub grpCustName_Format(Cancel As Integer, FormatCount As Integer)

'Me.grpCustName.Visible = (Nz(txtQ11Amt.Text) = 0) And (Nz(txtQ12amt.Text) = 0)
'Me.grpCustName.Visible = (Nz(txtQ11Amt) = 0) And (Nz(txtQ12amt) = 0)
'Cancel = (Nz(txtQ11Amt.Text) = 0) And (Nz(txtQ12amt.Text) = 0)

End Sub

我已尝试了几件事,但在我的代码运行之前仍然收到“无效的过程调用”。 “无效过程调用”以黄色突出显示以“Private grpCustName_Format ...”开头的函数头。

我忘了链接图书馆或其他什么? 这可能有什么问题?

谢谢。

编辑:我在2015年第一季度销售框中的公式:=DSum("[sls_amt]","tblSalesLastYear","[sls_amt] <> 0 and [billed_dt] >= 20150101 and [billed_dt] <= 20150331 and [cus_no] = [txtCustno] ")。 2016年第一季度销售箱中的公式相同,但日期不同。

1 个答案:

答案 0 :(得分:0)

这应该做:

Private Sub grpCustName_Format(Cancel As Integer, FormatCount As Integer)

    Me.grpCustName.Visible = (Nz(txtQ11Amt.Value, 0) = 0 And Nz(txtQ12amt.Value, 0) = 0)

End Sub

替代语法:

    Me!grpCustName.Visible = (Nz(Me!txtQ11Amt.Value, 0) = 0 And Nz(Me!txtQ12amt.Value, 0) = 0)

更正可见:

    Me!grpCustName.Visible = Not (Nz(Me!txtQ11Amt.Value, 0) = 0 And Nz(Me!txtQ12amt.Value, 0) = 0)
相关问题