Use the DoEvents Command to Yield Execution to Other Processes During Loops in Microsoft Access
HTML-код
- Опубликовано: 31 июл 2024
- 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.
BECOME A MEMBER:
RUclips: / @599cd
or My Site: 599cd.com/THMember
LEARN MORE:
599cd.com/DoEvents
PREREQUISITES:
Intro to VBA: 599cd.com/IntroVBA
For Next Loops: 599cd.com/ForNext
If Then: 599cd.com/IfThen
Variables: 599cd.com/Variables
RECOMMENDED COURSES:
Access Developer Courses: 599cd.com/Developer
FREE TEMPLATE DOWNLOADS:
TechHelp Free Templates: 599cd.com/THFree
Blank Template: 599cd.com/Blank
Contact Management: 599cd.com/Contacts
Order Entry & Invoicing: 599cd.com/Invoicing
More Access Templates: 599cd.com/AccessTemplates
ADDITIONAL RESOURCES:
FREE Access Beginner Level 1: 599cd.com/Free1
How to Use Access in 30 Minutes: 599cd.com/30Minutes
$1 Access Level 2: 599cd.com/1Dollar
Donate to my Tip Jar: 599cd.com/TipJar
Get on my Mailing List: 599cd.com/YTML
Contact Me: 599cd.com/Contact
TechHelp: 599cd.com/TechHelp
Consulting Help: 599cd.com/DevNet
Twitter: / learningaccess
en.wikipedia.org/wiki/Microso...
products.office.com/en-us/access
microsoft.com/en-us/microsoft...
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
QUESTIONS:
Please feel free to post your questions or comments below. Thanks.
Thanks for the video! I really liked the use of "Mod" to not display every "print" item.
That’s even better then the calculator! 😊
Thank you! Great video! 👍
You're very welcome
Thanks, Richard, I've learned something new ... thanks. :)
You're very welcome
I came across this problem when I was scanning several folders on different hard drives to add videos into my database.
I used SysCmd acSysCmdSetStatus I got a progress update in the bottom left hand side telling me how far the drive scan had progressed. But I do like DoEvents I am going to play with it. I do think the screen is a better place to display information. There always appears to be an easier way to do stuff in Access.
I have found Richard Rost often has the simplest solutions. In fact Microsoft is probably the last place to look to solve your problems. There is always an easier way. Thank you.
Microsoft's website has a lot of great technical information but not a lot of how to. Which is okay because that's where I come in. LOL. I liken Microsoft's website to a reference book that's not necessarily great for learning something but good for looking something up once you kind of already sort of know how to do it.
@@599CD That reminds me of when I was a kid. If i could not spell a word, how could I find it in the dictionary? You have to know how the word is spelt to find it. Then you don't need a dictionary do you? Unless you need to find out what the word means. A bit like my programming. I have several routines some I do not understand exactly how they work but they do. That's good enough for me. I think people use words and they have no idea what they mean but they use them anyway. Have a great day.
Very helpful ❤
Thanks
It's not exactly related to this video (what with the DoEvent function), but it made me want to put an abort function for a subroutine (and a series of related subroutines, toggled by checkboxes, within the main subroutine) utilizing a long series of followhyperlink / sendkeys / sleep functions to perform searches in a nuymber of online repositories. The aim is to help minimize some of the redundant tasks for my end users.
Yeah I put abort buttons near anything that runs in Loops or has lots of steps
I'd suggest a on screen display updated every 20 seconds or so displaying the time so a user knows the process is moving
Yep you could indeed use time as a counter variable in fact someone else already asked me how to do this a little while back and it's on my list for a video so stay tuned
The doggy doorman works for free BTW
He gets paid in treats.
@@599CD our pets treats are called "candy" to them, as for human food, they get dibs on cleaning the dishes first