将ControlSource属性与表达式一起使用 [英] Using ControlSource Property with an expression

查看:92
本文介绍了将ControlSource属性与表达式一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在连续表单上有一个文本框,我想显示一个计算值。我设置了ControlSource Property = [text1]& "〜" &安培; [text2]。


我希望我的用户能够更正此值,我将使用VBA代码取消计算。


根据Access(2000)帮助,我可能有一个ControlSource的表达式,控件显示由表达式生成的数据。该数据可由用户更改,但不保存在数据库中。这很好,但我不能让它发挥作用。可以捕获LostFocus,Click,MouseDown,Enter,Exit等事件,但不能在文本框中输入任何内容。我得到一个有吸引力的铃声。


当然,我的实际问题更复杂,但这个简单的例子很好地说明了它。表:

1 AAA aaa

2 BBB bbb

3 XXX xxx

表格有3个文本框,带有ControlSources = text1,text2和[text1]& "〜" &安培; [text2]


这里有什么帮助吗?


OldBirdman

I have a textbox on a continuous form that I want to display a calculated value. I have set the ControlSource Property = [text1] & "~" & [text2].

I would like to have my user be able to correct this value, and I will un-calculate it using VBA code.

According to Access(2000) Help, I may have an expression for a ControlSource, "The control displays data generated by an expression. This data can be changed by the user but isn''t saved in the database." This is good, but I can''t make it work. Events such as LostFocus, Click, MouseDown, Enter, Exit can be trapped, but nothing can be entered into the textbox. I get an attractive chime sound.

Of course, my actual problem is more complex, but this simple example illustrates it nicely. Table:
1 AAA aaa
2 BBB bbb
3 XXX xxx
Form has 3 textboxes, with ControlSources = text1, text2, and [text1] & "~" & [text2]

Any help here?

OldBirdman

推荐答案

< a href =https://bytes.com/topic/access/answers/857899-using-controlsource-property-expression#post3442822 =nofollowclass =at_reply> @OldBirdman


将控制源更改为表达式的语法

< some field> on<某种形式>是:
@OldBirdman
The syntax for changing the Control Source to an Expression for
<some field> on <some form> is:
展开 | 选择 | Wrap | 行号


帮助不正确! 控制源控制源!它不能由用户或通过代码更改。


要做你想做的事情并且仍然可以编辑,你需要使用两个文本框的 AfterUpdate 事件来分配值:

Help is incorrect! The Control Source is the Control Source! It cannot be changed by the user or thru code.

To do what you want and still have it editable, you need to assign the value using the AfterUpdate events of the two textboxes:

展开 | 选择 | Wrap | 行号


@missinglinq


Hello Linq,除非我完全读取此线程不正确,控制源最明确地可以以其中的方式更改我描述并在OPs条件下,即:
@missinglinq
Hello Linq, unless I am totally reading this Thread incorrectly, the Control Source can most definately be changed in the manner in which I described and under the OPs condition, namely:

"控件显示由表达式生成的数据。该数据可由用户更改,但不保存在数据库中。
"The control displays data generated by an expression. This data can be changed by the user but isn''t saved in the database."



表达式还将为连续表格中的每个记录生成唯一值。

The Expression will also generate unique values for each Record in the Continuous Form.


这篇关于将ControlSource属性与表达式一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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