Use the DoEvents Command to Yield Execution
In this Microsoft Access tutorial I'm going to teach you how to use the DoEvents command inside of a loop to yield execution to the database so that it can do stuff like update the screen and show your user that the database is busy doing something and not necessarily locked up.
Notes
- I didn't think of adding this until after I finished recording and posting the video but a few people have asked me if they can use DoEvents to allow the user to continue working in the database while something runs in the background. While this is technically possible I don't recommend it. If you've got one loop running an Access I would just let it run and do its thing. If you try to do other work while that loop is running, especially if it's updating the screen, you may lose focus on an important field that you're typing in and other weird stuff can happen. Fortunately, Windows is really good at multitasking so what you could do is open a second database and work on that one while your first database does its thing. And of course you don't want to modify anything that has to do with the records that that loop is working on.
Prerequisites
Recommended Courses
Keywords
access 2016, access 2019, access 2021, access 365, microsoft access, ms access, ms access tutorial, #msaccess, #microsoftaccess, #help, #howto, #tutorial, #learn, #lesson, #training, #database, What is the DoEvents function, not responding, yield execution, mod, modulus, for next, if then, variables