更新时在VBA中计算的更新表单字段 [英] Update Form fields calculated in VBA on change

查看:96
本文介绍了更新时在VBA中计算的更新表单字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

展开 | 选择 | Wrap | 行号

推荐答案

尝试在查询中进行计算并将表单绑定到该计算。然后计算应该自己刷新。
Try doing the calculations in a query and bind your form to that. Then the calculations should refresh themselves.


如果你有很多这样的计算。 (这可能需要进一步定义),这可能会大大减慢查询速度。例如,如果您有1,000条记录,每条记录需要25次复杂的计算,这可能会非常慢,具体取决于您的系统。


一般情况下,我同意Seth的说法查询级别的计算最好。但是,您似乎担心更新表单本身的值,这样可以更好地处理表单级别的计算,而不是查询级别。在查询级别的计算需要重新查询,这可能(取决于许多这样的计算意味着什么)需要额外的时间。


在你的情况下,我总是计算 AfterUpdate 事件。它通常是最简单的。


当然,如果您有多个基于多个字段的计算,则需要确定正确的操作顺序,以便所有计算都正确。 br />

===========================


作为旁注,我最近看到很多海报尝试使用 除了 AfterUpdate 事件,对我而言,似乎是最合乎逻辑的起点。我想知道他们是否从推荐这种方法的地方学习这个?
If you have "many such calculations" (this might need further definition), this could slow down the query considerably. For example, if you have 1,000 records and each record requires 25 complicated calculations, this could be quite slow, depending on your system.

In general, I would agree with Seth, that performing calculations at the query level would be best. However, it appears that you are concerned about updating values on the form itself, which would then lend itself better to calculations at the form-level, rather than the query level. Calculations at the query level, would require a requery, which could (depending on what "many such calculations" means) take extra time.

In your case, I would always calculate on the AfterUpdate Event. It is usually the easiest.

Of course, if you have multiple calculations based upon multiple fields, you need to determine the proper order of operations, so that all the calculations are correct.

===========================

As a side note, I have seen a lot of posters here lately trying to perform lots of functions on changed values in controls using everything but the AfterUpdate Event, which, to me, just seems to be the most logical place to start. I am wondering if they are learning this from somewhere that recommends this method?


感谢您的回复。我使用AfterUpdate但没有计算。我复制了一些代码。也许我需要添加别的东西?就像订单一样,许多计算需要跳来拉动它的信息。虽然它不是随机我不知道如何订购它。
Thanks for the replies. I used AfterUpdate but nothing calculated. I copied some code. Maybe I need to add something else? Far as order many calculations need to jump around to pull its info. Although its not random Im not sure how to order it.
展开 | 选择 | Wrap | 行号


这篇关于更新时在VBA中计算的更新表单字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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