Access 2010 表达式生成器
我想要一个文本框包含基于 2 个其他控制字段值进行计算的数据 - 仅当其值为空时(即数据库中列的当前值为空)。
因此,我在默认值属性的表达式生成器中输入 =([control1]*[Control2])/1000 - 但结果始终显示文本框为空(即使 control2 和 control2 包含值)。
我怎样才能实现这个目标?这样的操作只能在代码隐藏即VB中完成吗?
谢谢,
KS
I want a text box to contain data which is a calculation based on 2 other control field values - only if it's value is null (ie the current value of the column in the database is null).
So I entered =([control1]*[Control2])/1000 in the expression builder for the default value property - however the result always shows the textbox to be empty (even tho control2 and control2 contain values).
How can I achieve this? Can such an operation only be done in code-behind ie VB??
thanks,
KS
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您正在谈论绑定到表单记录源中的字段的控件。当基础字段为 Null 时,您希望控件加载您的计算值。
如果该解释正确,您可以通过表单的 On Current 事件来执行此操作。
这会将计算的值加载到文本框中,允许用户根据需要更改其值,并在保存记录时将该值存储到绑定字段。
如果绑定字段不为 Null,则其值将显示在文本框中,而不会被 On Current 代码更改。
这就是你想要的吗?
I think you're talking about a control bound to a field in the form's record source. And when the underlying field is Null, you want the control loaded with your calculated value.
If that interpretation is correct, you can do it from the form's On Current event.
That will load the computed value into the text box, allow the user to change its value if desired, and store the value to the bound field when the record is saved.
If the bound field is not Null, its value will be displayed in the text box without alteration by the On Current code.
Is that what you want?
要使用 VBA 完成此操作,请添加 Form_Load 事件。 (在“设计视图”中打开表单,在“表单属性”中单击“事件”选项卡,然后为“加载时”选择“事件过程”,然后单击...)
此示例使用 [TextField] 引用表数据。
To accomplish this using VBA, add a Form_Load Event. (Open the form in Design View and in Form properties click the Event tab and choose Event Procedure for "On Load" and click ...)
This example uses [TextField] to refer to the table data.