条件格式问题 [英] Conditional formatting problem

查看:84
本文介绍了条件格式问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如果它是空的,我想让一个绑定的文本框不可见(不仅仅是

禁用它)。标准的条件

格式化功能无法使用此选项(至少,我找不到)。


我想调用类模块函数通过Expression Builder获取

控件。我已经写了一个基本功能,但似乎无法正确传递相关参数。在我看来,我需要传递

两个参数:控件的名称,以及数据库的价值

字段。该函数用于将控件的.Visible属性设置为

FALSE(如果为空)并将值返回到显示(空白或一些

其他值)。我想把这个功能变得通用,这样我就可以在将来使用它来对任何表格进行任何控制。


这就是我所拥有的功能:


''---------------

公共函数HideIfEmpty(CtlName As Variant, ctlValue As Variant)_

As Variant


Dim ctl As Control


设置ctl = CtlName

HideIfEmpty = ctlValue

ctl.Visible = Iif(Nz(ctlValue,"")="",False,True)


结束功能

''--------------


我认为我的主要问题是通过CtlName值。如果函数是通用的,那么

需要是一个完全限定的路径名​​,但是

使用Expression Builder选择控件,只有本地控制名

已插入。因此,表达式生成器结果如下所示:


= HideIfEmpty([txtControlname],[FieldValue])


运行表单时,函数给出错误2427你输入了一个没有价值的

表达式。


Obvioulsy我没有正确地这样做。任何指针都会很高兴

赞赏!


干杯,

Lyn。

Hi,
I would like to make a bound text box not visible if it is empty (not just
disable it). This option is not available from the standard conditional
formatting feature (at least, not that I can find).

I thought of calling a class module function via Expression Builder for the
control. I have written a basic function, but don''t seem to be able to
pass the relevant arguments correctly. It seems to me that I need to pass
two arguments: the name of the control, and the value of the database
field. The function is intended to set the control''s .Visible property to
FALSE (if it is empty) and to return the value to display (blank or some
other value). And I would like to make the function generic so that I can
use it in future for any control on any form.

This is what I have so far for the function:

''---------------
Public Function HideIfEmpty(CtlName As Variant, ctlValue As Variant) _
As Variant

Dim ctl As Control

Set ctl = CtlName
HideIfEmpty = ctlValue
ctl.Visible = Iif(Nz(ctlValue,"") = "", False, True)

End Function
''--------------

I think that my main problem is in passing the CtlName value. This would
need to be a fully qualified pathname if the function is to be generic, but
selecting the control using Expression Builder, only the local controlname
is inserted. Thus the Expression Builder result looks like:

=HideIfEmpty([txtControlname],[FieldValue])

When running the form, the function gives an error 2427 "You entered an
expression that has no value."

Obvioulsy I am not doing this correctly. Any pointers would be much
appreciated!

Cheers,
Lyn.

推荐答案

On Sun,2007年6月10日12:36:34 +1000,Lyn写道:
On Sun, 10 Jun 2007 12:36:34 +1000, Lyn wrote:



如果它是空的,我想使一个绑定的文本框不可见(不仅仅是

禁用它)。标准条件

格式化功能无法使用此选项(至少,我找不到)。
Hi,
I would like to make a bound text box not visible if it is empty (not just
disable it). This option is not available from the standard conditional
formatting feature (at least, not that I can find).



[snip]

[snip]


这是我到目前为止的功能:


''---------- -----

公共函数HideIfEmpty(CtlName As Variant,ctlValue As Variant)_

As Variant


Dim ctl作为控制


设置ctl = CtlName

HideIfEmpty = ctlValue

ctl.Visible = Iif(Nz(ctlValue,"" ;)="",False,True)


结束功能

''--------------


我认为我的主要问题是传递CtlName值。
This is what I have so far for the function:

''---------------
Public Function HideIfEmpty(CtlName As Variant, ctlValue As Variant) _
As Variant

Dim ctl As Control

Set ctl = CtlName
HideIfEmpty = ctlValue
ctl.Visible = Iif(Nz(ctlValue,"") = "", False, True)

End Function
''--------------

I think that my main problem is in passing the CtlName value.



好​​的,我已经完成了一半工作。我在

淋浴时遇到了这个问题(正如你所做的那样),我觉得我不应该将

控件名称作为Variant传递给我,但控件本身作为控件对象。

将函数头更改为以下内容:

公共函数HideIfEmpty(CtlName作为Control,ctlValue作为Variant)_

作为Variant


现在在连续子表单中的情况(

问题中的控件所在的位置)是,如果所有行中的文本框都是空白的,然后

文本框在所有行中都不可见。但是,如果

ANY行中的文本框包含非空白数据,它将在所有行中显示。


我原以为任何表达式生成器对照的表达式是逐行解决的。

。显然情况并非总是如此。


所以现在我的问题已经改为:我怎么能逐行地做到这一点

(而不是到目前为止我得到的全有或全无的结果。


再次感谢任何珍贵的智慧!


干杯,

Lyn。

OK, I''ve got it half working. I was agonizing over the problem in the
shower (as you do) and it came to me that I shouldn''t be passing the
control NAME as a Variant, but the control itself as a control object.
Changed the function header to the following:

Public Function HideIfEmpty(CtlName As Control, ctlValue As Variant) _
As Variant

The situation now in the continous subform (where the control in
question is located), is that if the text box is blank in all rows, then
the text box will be not Visible in all rows. However, if the text box in
ANY row contains non-blank data, it will be visible in ALL rows.

I had thought that any Expression Builder expression for a control was
resolved on a row-by-row basis. Apparently this is not always the case.

So now my question has changed to: how can I do this on a row-by-row basis
(rather than the all-or-nothing result I am getting thus far).

Thanks again for any pearls of wisdom!

Cheers,
Lyn.


Lyn写道:
Lyn wrote:

>在Sun,10 Jun 2007 12:36:34 +1000,Lyn写道:
>On Sun, 10 Jun 2007 12:36:34 +1000, Lyn wrote:

>
我想让一个绑定的文本框不可见如果它是空的(不只是
禁用它)。标准条件
格式化功能无法使用此选项(至少,我找不到)。
>Hi,
I would like to make a bound text box not visible if it is empty (not just
disable it). This option is not available from the standard conditional
formatting feature (at least, not that I can find).


[snip]

[snip]


>这是我到目前为止的功能:

''---------------
公开函数HideIfEmpty(CtlName As Variant,ctlValue As Variant)_
As Variant

Dim ctl As Control

设置ctl = CtlName
HideIfEmpty = ctlValue
ctl.Visible = Iif(Nz(ctlValue,"")="",False,True)

结束功能
''------ --------

我认为我的主要问题是传递CtlName值。
>This is what I have so far for the function:

''---------------
Public Function HideIfEmpty(CtlName As Variant, ctlValue As Variant) _
As Variant

Dim ctl As Control

Set ctl = CtlName
HideIfEmpty = ctlValue
ctl.Visible = Iif(Nz(ctlValue,"") = "", False, True)

End Function
''--------------

I think that my main problem is in passing the CtlName value.


好的,我已经完成了一半工作。我在
淋浴中遇到了这个问题(正如你所做的那样),我觉得我不应该将
控件名称作为Variant传递,而是将控件本身作为控件对象传递给我。
将函数头更改为以下内容:

公共函数HideIfEmpty(CtlName作为Control,ctlValue作为Variant)_
As Variant

情况现在在连续子表单中(
问题中的控件所在的位置),如果所有行中的文本框都是空白的,那么文本框在所有行中都不可见。但是,如果任何行中的文本框包含非空数据,则它将在所有行中可见。

我原以为控件的任何表达式构建器表达式都是
逐行解决。显然情况并非总是如此。

所以现在我的问题已经变成:我怎样才能逐行地做到这一点
(而不是全有或全无)结果我到目前为止)。


OK, I''ve got it half working. I was agonizing over the problem in the
shower (as you do) and it came to me that I shouldn''t be passing the
control NAME as a Variant, but the control itself as a control object.
Changed the function header to the following:

Public Function HideIfEmpty(CtlName As Control, ctlValue As Variant) _
As Variant

The situation now in the continous subform (where the control in
question is located), is that if the text box is blank in all rows, then
the text box will be not Visible in all rows. However, if the text box in
ANY row contains non-blank data, it will be visible in ALL rows.

I had thought that any Expression Builder expression for a control was
resolved on a row-by-row basis. Apparently this is not always the case.

So now my question has changed to: how can I do this on a row-by-row basis
(rather than the all-or-nothing result I am getting thus far).



您缺少的一点就是只有**一个**文件

框。这意味着只有一组属性

供您操作,因此当您设置Visible属性时,

它适用于控件的所有副本。 />

连续

表格中行与行之间的唯一不同之处是控件的值以及它是如何通过
$格式化的b $ b格式属性和条件格式。


由于您无法通过设置

可见属性(或任何其他属性)来获得所需的效果,你应该考虑使用Condiftional Formatting来模拟它。

也许通过将背面颜色设置为与

形式相同的颜色背面颜色。


-

Marsh


The point you are missing is that there is only **one** text
box. This means that there is only one set of properties
for you to manipulate so when you set the Visible property,
it applies to all the copies if the control.

The only things that vary from row to row in a continuous
form is the value of the control and how it''s formatted via
the Format property and Conditional Formatting.

Since you can not get the desired effect by setting the
Visible property (or any other property), you should
consider simulating it by using Condiftional Formatting.
Perhaps by setting the back color to the same color as the
form''s back color.

--
Marsh


On Sun,2007年6月10日10:39 :20 - 0500,Marshall Barton写道:
On Sun, 10 Jun 2007 10:39:20 -0500, Marshall Barton wrote:

>

你缺少的一点就是**只有** **文字

框。这意味着只有一组属性

供您操作,因此当您设置Visible属性时,

它适用于控件的所有副本。
>
The point you are missing is that there is only **one** text
box. This means that there is only one set of properties
for you to manipulate so when you set the Visible property,
it applies to all the copies if the control.



这已经很明显了。我曾经遇到过类似的问题,当时我想要在一个图像控件中列出缩略图片 - 由于同样的原因,它不能完成

This much had become obvious. I had a similar problem once before when I
was trying to list thumbnail pictures in an Image control -- it can''t be
done for the same reason.


连续

形式中行与行之间的唯一不同之处是控件的值以及它是如何通过格式化的

格式属性和条件格式。
The only things that vary from row to row in a continuous
form is the value of the control and how it''s formatted via
the Format property and Conditional Formatting.



这是因为你可以逐行格式化数据,我希望

它可以做其他的这样的事情。我的希望是徒劳的!

(但值得一试:-)

It was because you can format data on a row-by-row basis that I was hoping
it might be possible to do other things this way. My hope was in vain!
(But worth trying :-)


因为你无法通过设置
可见属性(或任何其他属性),你应该考虑使用条件格式来模拟它。

也许通过将背景颜色设置为相同颜色为

形成'背面颜色。
Since you can not get the desired effect by setting the
Visible property (or any other property), you should
consider simulating it by using Condiftional Formatting.
Perhaps by setting the back color to the same color as the
form''s back color.



这总是我的后备位置。但在诉诸于此之前,我认为我会看到是否有其他解决方案。显然不是。遗憾

条件格式限制如此严格 - 您可以切换启用

属性但不能切换Lock或Visible属性 - 以及可用范围

颜色很小。


无论如何,谢谢你的回复。你已经确认我怀疑了!


干杯,

Lyn。

This was always my fallback position. But before resorting to that, I
thought I would see if there were other solutions. Apparently not. Pity
that Conditional Formatting is so restrictive -- you can toggle the Enable
property but not the Lock or Visible property -- and the range of available
colours is quite small.

Anyway, thanks for your response. You have confirmed what I suspected!

Cheers,
Lyn.


这篇关于条件格式问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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