469,570 Members | 1,717 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Share your developer knowledge by writing an article on Bytes.

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 6800

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 suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.