检查OnFormat报告中的字段值? [英] Check for field value from within a report OnFormat?

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

问题描述

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

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

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

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

结束子


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

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

解决方案

2005年11月10日星期四12:06:42 -0500,MLH写道:

Private Sub Detail_Format(取消为整数,FormatCount为整数)
如果LaborCost> 0然后我!LaborCost.Visible = True
如果MatlsCost> 0然后我!MatlsCost.Visible = True
如果OtherCost> 0然后我!OtherCost.Visible = True
End Sub

我在表格中使用与上述子类似的程序,在需要时在表格上制作控件。我无法在
报告的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

请仅回复此新闻组。

我不回复个人电子邮件


Thx,FredG。我的问题似乎在此之前就开始了。

当我在

即时窗口输入类似内容时出现错误:


?报告![MyReport]![text147]


我收到运行时错误#2427(我已经输入了一个没有价值的表达式

,它说 - 像表格或报告或

标签控制)。但事实并非如此。它确实是一个文本框控件。

它确实有一个值。


fredg< fg ****** @ example。无效>写在

新闻:11 ***************************** @ 40tude.net:

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

我!LaborCost.Visible =我!LaborCost> 0
我!MatlsCost.Visible =我!MatisCost > 0
Me!OtherCost.Visible = Me!OtherCost> 0




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


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


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

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

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

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

布尔表达式。


-

David W. Fenton http://www.bway.net/~dfenton

dfenton at bway dot net http://www.bway.net/~dfassoc


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?

解决方案

On Thu, 10 Nov 2005 12:06:42 -0500, MLH wrote:

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


Thx, FredG. My problem seems to start before that.
I get an error when I type something like this in the
immediate window:

?Reports![MyReport]![text147]

I get runtime error #2427 (I''ve entered an expression
that has no value, it says - like a form or a report or a
label control). But its not. It really is a textbox control.
And it does have a value.


fredg <fg******@example.invalid> wrote in
news:11*****************************@40tude.net:

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



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报告中的字段值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆