2

I have a basic SELECT query fired from an Access form that takes a while to execute, so I would like to run the query asynchronously and allow my users to continue using the form (or at least keep them updated on the progress).

The problem is that Access freezes the application when code is being executed, appearing to the users to have crashed - even to the point of Windows marking it 'Not Responding' and offering to kill it. Obviously not very user-friendly! I have tried using the code listed on the MSDN here and a variant method here.

Both these solutions do seem to run the query 'asynchronously' (the code block firing the async query completes, and the rs_FetchProgress and rs_FetchComplete events (or cn_ExecuteComplete event in the second solution) fire and run... but Access's interface still locks up until the query is done executing. Calling Repaint and DoEvents in various places (such as the rs_FetchProgress event) does not seem to have any effect.

I doubt it's relevant information, but the view being SELECTed from is in SQL Server, the view doesn't return a huge amount of data but does take about 20 seconds to process.

4

1 回答 1

1

打开表单时不要拉出巨大的记录集。表单基于一个查询,它在第一次加载时只提取很少甚至没有记录。然后为用户提供一种方法来选择不同的合理大小的记录子集。

无论您的数据源是链接的 Access 表还是客户端-服务器数据库,都尽量避免拉取大量记录集。

于 2013-04-05T14:22:30.530 回答