本文介绍了检查OnFormat报告中的字段值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Private Sub Detail_Format(取消为整数,FormatCount为整数)

如果LaborCost> 0然后我!LaborCost.Visible = True

如果MatlsCost> 0然后我!MatlsCost.Visible = True

如果是OtherCost> 0然后我!OtherCost.Visible = True

结束子


我在表格中使用类似于上述子程序来制作控件
$ b表格上的$ b可在需要时显示。我无法在

报告的OnFormat属性代码中完成此操作。我怎样才能在报告上做到这一点?

解决方案




您的代码应该可以正常运行,假设字段的值在

fact> 0 。但是,一旦该值变为< = 0,您将需要代码将控件Visible变为

false。


Private Sub Detail_Format(取消为整数,FormatCount As Integer)

如果LaborCost> 0然后

我!LaborCost.Visible = True

否则

我!LaborCost.Visible = false

结束如果

如果MatlsCost> 0然后

Me!MatlsCost.Visible = True

Else

Me!MatisCost.Visible = false

End如果

如果是OtherCost> 0然后

Me!OtherCost.Visible = True

Else

Me!OtherCost.Visible = false

End如果

End Sub


一种更简单的方法就是使用:


我!LaborCost.Visible = Me !LaborCost> 0

Me!MatlsCost.Visible = Me!MatisCost> 0

Me!OtherCost.Visible = Me!OtherCost> 0

-

Fred

请仅回复此新闻组。

我不回复个人电子邮件






为清楚起见,我认为最好这样做:


我!LaborCost.Visible =(我!LaborCost> 0)


否则,你依赖于VBA解析器/编译器来猜猜

正确地说你的意图。是的,对于

操作的订单有规则,在这个例子中,VBA会做对,但我认为

它总是更好地明确它,并强制评估

布尔表达式。


-

David W. Fenton

dfenton at bway dot net

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If LaborCost > 0 Then Me!LaborCost.Visible = True
If MatlsCost > 0 Then Me!MatlsCost.Visible = True
If OtherCost > 0 Then Me!OtherCost.Visible = True
End Sub

I use procedures similar to the above sub in forms to make controls
on the form visible when desired. I''m unable to accomplish this in a
report''s OnFormat property code. How can I do this on a report?

解决方案



Your code should work assuming that the values of the fields are in
fact >0. But you would then need code to turn the controls Visible to
false once the value then becomes <=0.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If LaborCost > 0 Then
Me!LaborCost.Visible = True
Else
Me!LaborCost.Visible = false
End If
If MatlsCost > 0 Then
Me!MatlsCost.Visible = True
Else
Me!MatisCost.Visible = false
End If
If OtherCost > 0 Then
Me!OtherCost.Visible = True
Else
Me!OtherCost.Visible = false
End If
End Sub

A simpler method would be to use:

Me!LaborCost.Visible = Me!LaborCost >0
Me!MatlsCost.Visible = Me!MatisCost >0
Me!OtherCost.Visible = Me!OtherCost >0
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail





For clarity, I think it''s better to do:

Me!LaborCost.Visible = (Me!LaborCost >0)

Otherwise, you''re depending on the VBA parser/compiler to guess
correctly about what you intended. Yes, there are rules for order of
operations and in this example, VBA would get it right, but I think
it''s always better to be explicit about it, and force evaluation of
the Boolean expression.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc


这篇关于检查OnFormat报告中的字段值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 19:01