效率问题?功能需要7-10秒才能完成/刷新 [英] Efficiency issues? Function takes 7-10 seconds to complete/refresh

查看:56
本文介绍了效率问题?功能需要7-10秒才能完成/刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个函数可以根据查询/表中的值在表单上绘制一些形状。然而,整个过程需要十秒钟,而且由于我是编码的新手,我想我可能会在使代码更高效方面获得很多好处......?


我的代码中是否有非常明显的时间消费者,可以更有效地解决这些问题?


我们将非常感谢任何指导。



(在数据库中,我有一个主表格)日历,其中有67个子表单(frmSub01-67),其中有图纸。成品或多或少看起来像这样:

I have a function to draw some shapes on a form depending on values in queries/tables. The whole procedure takes up to ten seconds however, and as I''m new to coding, I assume I might have a lot to gain on making my code more efficient...?

Are there any very obvious time-consumers in my code, which can be settled much more efficiently?

Any guidance would be greatly appreciated.



(In the db I have a main form "Calendar," which has 67 subforms (frmSub01-67) in which drawings are made. The "finished product" looks more or less like this:

展开 | 选择 | 换行 | 行号

推荐答案

我没有查看你的代码因为它很长。我会也许稍后再试。

我建议首先在代码运行时重新绘制。在代码开头添加 Docmd.Echo False ,最后添加 Docmd.Echo true

您还应该添加一个错误处理程序,在其中重新打开图形,否则如果发生错误,您将被卡在空白屏幕上。
I haven''t looked through your code as its quite lengthy. I will maybe give it a go later.
What I would suggest first is to turn of redrawing while your code runs. Add Docmd.Echo False at the start of your code and Docmd.Echo true at the end.
You should also add an error handler in which you turn the drawing back on, otherwise you will be stuck with an empty screen if an error occurs.


我很感激!


尤其是第47-62行和第73-93行的两个部分,它们占用了大部分时间。我可能会让它们变得相当粗糙......
i appreciate that!

it''s especially the two segments at line 47-62 and line 73-93, they eat up most of the time consumed. i might have made them rather chunky...


在我看来,漫长的处理时间与代码的效率无关,而是与任务的性质无关。除此之外,您还可以在不少于67个子表单上动态删除/创建控件,这本身就是一个很高的订单。我注意到有一些项目可能会在处理时间上有所增加:
It appears to me that the long processing time has nothing to do with the efficiency of the Code, but rather with the nature of the Task. Among other things, you are dynamically Deleting/Creating Controls on none less than 67 Sub-Forms, a tall order in and of itself. There are a few items that I noticed which may provide small gains in processing time:
  1. 始终显式引用对象所属的对象类型库。
  1. Always explicitly refer to the Object type Libraries to which Objects belong.
展开 | 选择 | Wrap | 行号


这篇关于效率问题?功能需要7-10秒才能完成/刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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