【发布时间】:2018-09-26 09:20:21
【问题描述】:
我正在解决一个 vba 遗留应用程序中的性能问题 - 出于任何我不知道的原因 - 通过
设置连续表单的记录源myForm.RecordSource = newRecordsource
在表单已经打开之后。单击按钮后应用过滤器:
DoCmd.ApplyFilter , "my filter sql"
我想在设置 RecordSource 之前设置一个默认过滤器,以便表单显示得更快。但我收到错误消息 2491:
The action or method is invalid because the form or report isn't bound to a table or query.@You tried to use the ApplyFilter or SearchForRecord action or method. However, the form or report you applied the filter to is not based on a table or query, so the form or report doesn't have any records to apply a filter to.@Use the SelectObject action or method to select the desired form or report before you run the ApplyFilter action. To base a form or report on a table or query, open the form or report in Design view, and enter the table or query name in the RecordSource property.
所以我必须设置过滤器!之后! RecordSource 已设置。但是在我设置 RecordSource 的那一刻,我的应用程序正在发送查询。所以在我的情况下,行 ("myForm.RecordSource = newRecordsource") 将需要大约 13 秒来执行。之后设置过滤器会导致更多的等待时间。
在我应用过滤器之前,有没有办法阻止表单加载所有数据集?由于整个应用程序(以及其他几个应用程序)按描述工作,我不能只更改 RecordSource 中的查询或将其设置为设计模式。
【问题讨论】:
-
通常的方法是首先使用“空白”记录加载表单记录集,例如 SELECT * from YourTable WHERE PkID = 0。然后在用户在相关表单上设置了一些标准
-
哦,我忘了提到我正在使用连续形式
标签: database vba ms-access filter