VBA ~ Form doesn't refresh while doing intense background processing...

Posted on 2011-05-13
Last Modified: 2012-05-11
I have an MS Access form that is used for managing some file processing (under the hood, it's reading various text files and updating tables with data from those files). As it's processing each file, I have some code that updates a text box on the form to provide the status (e.g. "Processing file 3 or 9").

Before starting, I prompt them with a yes/no message box to confirm that they want to process their data (it can take awhile).

However, when they click "Yes" (continue), the message box doesn't go away and the status text box doesn't update until AFTER it's completed processing. Not exactly what I was looking for!

I'm sure it's because it is just crunching so hard in the background that it's not updating the form along the way.  I've added a 'refresh' command, but that didn't seem to help.

I know I've seen something on this before (possibly a magazine or something).  Maybe using a timer (am I getting warmer?).  I've done some searching online, but didn't find anything.  Time to call in the experts.

Thanks in advance for the help.
Question by:careybroph
    LVL 77

    Accepted Solution

    I'm surprised the msgbox doesn't disappear
    You could try  

    if msgbox() = vbYes then
    me.textbox = "some value"
    ' then do the rest of your processing

    or maybe

    if msgbox() = vbYes then
    me.textbox = "some value"
    ' then do the rest of your processing


    Author Comment

    repaint didn't work.

    DoEvent did help.  After it completed the first cycle it repainted the screen.  I need to tinker around with it a bit to get the message box to disappear right away, but that shouldn't be too difficult.

    THANKS for the quick help (and on a Friday even!).  Nice way to end the week!

    Author Closing Comment

    THANKS Again!

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    In the previous article, Using a Critera Form to Filter Records (, the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
    In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now