仅在更新/更改了2个字段之一的值时运行查询 [英] Run query only if values of either of 2 fields have been updated/changed

查看:52
本文介绍了仅在更新/更改了2个字段之一的值时运行查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个追加查询,它与我表单上按钮的OnClick事件相关联。我希望只有在表单上更新了2个字段之一的值时才运行查询; 位置字段或已分配给字段。


即位置字段的值是否更改,或者是否为''AssignedTo''字段被更改,然后查询应该运行。

如果两个字段都已更新,查询也应运行。


查询代码如下所示:

展开 | 选择 | Wrap | 行号

解决方案

我之前做过类似的事情,虽然它确实有效,它可能不是最好的方式。这就是我的工作。在'模块中,在Option Explicit下面,我将变量声明为整数,如下所示:

展开 | 选择 | 换行 | 行号


< blockquote>使用表单的On Current事件来存储旧值。然后在运行查询之前进行检查以将旧值与当前值进行比较。


看起来我与Seth交叉发布。我实际上会存储该值,因为如果他们更改了值然后将其更改回来可以设置编辑变量。


I have an append query which is tied to the OnClick event of a button on my form. I want the query to run only if the values of either of 2 fields is updated on the form; the ''Location'' field or the ''Assigned To'' field.

i.e. if the value of the ''Location'' field is changed, or if the value of the ''AssignedTo'' field is changed, then the query should run.
The query should also run if both fields have been updated.

The query code is below:

Expand|Select|Wrap|Line Numbers

解决方案

I have done something similar to this before and while it does work, it might not be the best way. Here is what I do. In the form''s module, right under the Option Explicit, I declare a variable as an integer, like this:

Expand|Select|Wrap|Line Numbers


Use the On Current event of the form to store the old values. Then put in a check to compare the old value to the current value before you run the query.


Looks like I cross posted with Seth. I would actually store the value because they can the edit variable to be set if they change the value and then change it back.


这篇关于仅在更新/更改了2个字段之一的值时运行查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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