471,888 Members | 2,485 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 471,888 developers and data experts.

Running code asynchronously

181 Expert 100+
Somtimes we need to run some code asynchronously. I'll explain this by example.
Suppose you have a listbox and you need to perform some action in the listbox AfterUpdate event procedure. But the problem is that your action is pretty heavy (it involves opening recordset based on complicated query, making some calculations and hiding \ viewing controls, based on the results). So when the user tries to "walk" through the list pressing Up and Down arrows (triggering AfterUpdate event at each step), it appears to be VERY slow.
The solution I present here uses the ability of Access to evaluate calculated fields asynchronously.
1. Create a function in form module.
Expand|Select|Wrap|Line Numbers
  1. Function MyAction() As String
  2. 'put your action code here
  3. End Function
2. On the form, create hidden field with ControlSource as
Expand|Select|Wrap|Line Numbers
  1. =[ListBox1] & MyAction()
This scheme will work like AfterUpdate event, except the case when listbox selection changes too fast. In that case, the MyAction function will only run at the final step, without slowing down user selection.
May 21 '07 #1
0 7094

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

7 posts views Thread by mircu | last post: by
2 posts views Thread by =?Utf-8?B?QWxwaGFwYWdl?= | last post: by
reply views Thread by YellowAndGreen | last post: by
reply views Thread by zermasroor | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.