Ms-access查询性能
我在数据表视图中显示了一个子表单,它具有如下所示的记录源:
SELECT MyTable.*, myFunction(MyTable.id) as my_result FROM MyTable
其中 myFunction() 是一个调用 MySQL 存储过程的 vba 函数。
问题是 myFunction()
被调用得太频繁了。例如,每当焦点在同一记录中从一列移动到另一列时,即使该记录保持不变,它也会被调用。有什么办法可以阻止这种情况发生吗?
I have a sub-form displayed in datasheet view that has a record source like this:
SELECT MyTable.*, myFunction(MyTable.id) as my_result FROM MyTable
Where myFunction()
is a vba function that makes a call to a MySQL stored procedure.
The problem is that myFunction()
is getting called far too often. For example it gets called whenever the focus is moved from column to column within the same record even though the record remains unchanged. Is there any way to stop this from happening?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当焦点位于链接字段时,字段的值将被刷新。
您的问题没有“简单”的解决方案。
但是,如果您可以在访问数据库中进行一些更改,您可以:
- 创建一个进程,用“myFunction()”结果填充 MyTable 中的字段
- 每次显示子表单或每次子表单中当前记录更改时调用此过程
或者您可以:
- 将未分离的字段添加到您的子表单中
- 每次子表单中当前记录发生更改时,通过代码将“myFunction()”调用的结果放入其中
When the focus is given to a linked field, the values of fields are refreshed.
No "simple" solution to your question.
But, if you can do some changes in the access database, you could :
- create a process that fill a field in MyTable with the "myFunction()" result
- call this process each time you display the sub-form or each time the current record change in the sub-form
Or you can :
- add a not detached field to your sub-form
- put in it by code the result of "myFunction()" call each time the current record change in your sub-form
听起来 MyFunction() 不应该在 SQL 语句中调用,而应该在表示层中调用,例如,作为用于显示数据的表单上的控件的 ControlSource。
Sounds like MyFunction() should not be called in the SQL statement but in the presentation layer, e.g., as the ControlSource of a control on the form you're using to display your data.