> ## Content Index
> Fetch the complete content index at: https://nolongerset.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# DoEvents vs. Repaint in Microsoft Access
- URL: https://nolongerset.com/doevents-vs-repaint/
- Published: 2021-07-27T03:58:00.000Z
- Updated: 2026-05-08T13:03:26.000Z
- Description: Can you use the Repaint method in place of the DoEvents function? It depends on what you're trying to do. Let's explore with some sample code.
- Author: Mike Wolfe
- Tags: DoEvents, Intermediate, #Import 2026-05-20 02:59

This is bonus 1 of a [multi-part series](https://nolongerset.com/demystifying-doevents/) on the DoEvents function.

---

In [part 3](https://nolongerset.com/when-to-call-doevents/) of my series of articles exploring the DoEvents function, I showed the following demonstration of the difference between running a loop without a DoEvents call vs. one with a DoEvents call.

> Microsoft Access is single-threaded. The code and the user interface both run on the same thread. If you want to provide form updates during a long-running process (like for a custom progress meter form), you need to explicitly give the UI a chance to update itself.

![](https://storage.ghost.io/c/eb/d7/ebd732c1-5f03-4f07-b386-5d08557e15c9/content/images/2021/07/DoEvents-2.gif)

## Question from Joakim Dalby

On LinkedIn, Joakim Dalby asked a follow-up question about that article:

> Could Me.Refresh or Me.Repaint or Me.Recalc replace your DoEvents in your test form?

## My response on LinkedIn

I just tested these three options using my demo form (<https://nolongerset.com/doevents-demo>/). 

**Me.Refresh** had no effect. 

**Me.Recalc** resulted in the Status Bar showing "Calculating...", but had no other obvious effect.  
  
**Me.Repaint** \*did\* result in the UI being updated. However, it did not allow the Cancel button to work.  
  
So, in certain situations, Me.Repaint could be preferable to DoEvents, as it is more precise in what it does. Good call!

### The Form Repaint Method

From the official [Microsoft docs](https://docs.microsoft.com/en-us/office/vba/api/access.form.repaint):

> The **Repaint** method completes any pending screen updates for a specified form. When performed on a form, the **Repaint** method also completes any pending recalculations of the form's controls.

The documentation goes on to clarify the difference between the Repaint method and the Refresh method:

> Don't confuse the **Repaint** method with the **[Refresh](https://docs.microsoft.com/en-us/office/vba/api/access.form.refresh)** method, or with the **Refresh** command on the **Records** menu. The **Refresh** method and the **Refresh** command show changes that you or other users have made to the underlying record source for any of the currently displayed records in forms and datasheets. The **Repaint** method simply updates the screen when repainting has been delayed while Access completes other tasks.

The [Recalc method](https://docs.microsoft.com/en-us/office/vba/api/access.form.recalc) simply forces a recalculation of any calculated controls.

### Updated demo

I updated my previous demonstration to show the effect of calling Me.Repaint instead of DoEvents within the loop.

![](https://storage.ghost.io/c/eb/d7/ebd732c1-5f03-4f07-b386-5d08557e15c9/content/images/2021/07/Repaint_vs_DoEvents.gif)

Me.Repaint updates the current count, but the Cancel click does not get processed.

Here is the code-behind for the above form:

```vba
Option Compare Database
Option Explicit

#If VBA7 Then
    Private Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
#Else
    Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
#End If

Private mUserCanceled As Boolean

Private Sub RunLoop(YieldCommand As String)
    mUserCanceled = False
    DoCmd.Hourglass True
    Me.tbCount.Value = 0
    
    Dim i As Long
    For i = tbStart.Value To tbEnd.Value
        If mUserCanceled Then Exit For
        Sleep tbDelay.Value
        Me.tbCount.Value = i
        Select Case YieldCommand
        Case "Nothing"
            'Do nothing to yield execution
        Case "Repaint"
            Me.Repaint
        Case "DoEvents"
            DoEvents
        End Select
    Next i
    DoCmd.Hourglass False
End Sub

Private Sub btnNoDoEvents_Click()
    RunLoop "Nothing"
End Sub

Private Sub btnRepaint_Click()
    RunLoop "Repaint"
End Sub

Private Sub btnWithDoEvents_Click()
    RunLoop "DoEvents"
End Sub

Private Sub btnCancel_Click()
    mUserCanceled = True
End Sub
```

If you want to play with the code yourself, there is a sample database available here: [TestDoEvents-v2.zip](https://assets.nolongerset.com/TestDoEvents-v2.zip)

---

### Referenced articles

[Demystifying DoEventsThe DoEvents function may be the single most misunderstood piece of code in the entire VBA language. In this series of articles, I’ll try to remedy that.![](https://nolongerset.com/favicon.png)No Longer SetMike Wolfe![](https://storage.ghost.io/c/eb/d7/ebd732c1-5f03-4f07-b386-5d08557e15c9/content/images/2021/07/death-164761.jpg)](https://nolongerset.com/demystifying-doevents/)

[When (or Should I Say, How Often) to Call DoEventsToo few calls to DoEvents, and your app may appear to be ”(Not Responding).” Too many calls to DoEvents, and your app will run slow. Let’s Goldilocks this thing.![](https://nolongerset.com/favicon.png)No Longer SetMike Wolfe![](https://storage.ghost.io/c/eb/d7/ebd732c1-5f03-4f07-b386-5d08557e15c9/content/images/2021/07/hans-jurgen-mager-NL1vH0hnIbQ-unsplash.jpg)](https://nolongerset.com/when-to-call-doevents/)

### External references

[Mike Wolfe on LinkedIn: When (or Should I Say, How Often) to Call DoEventsToo few calls to DoEvents, and your app may appear to be ”(Not Responding).” Too many calls to DoEvents, and your app will run slow. Let’s Goldilocks...![](https://static-exp1.licdn.com/sc/h/al2o9zrvru7aqj8e1x2rzsrca)LinkedIn35 Posts![](https://storage.ghost.io/c/eb/d7/ebd732c1-5f03-4f07-b386-5d08557e15c9/content/images/2021/07/hans-jurgen-mager-NL1vH0hnIbQ-unsplash.jpg)](https://www.linkedin.com/feed/update/urn:li:activity:6822392885422387200/?commentUrn=urn%3Ali%3Acomment%3A%28activity%3A6822392885422387200%2C6822404531159126016%29&replyUrn=urn%3Ali%3Acomment%3A%28activity%3A6822392885422387200%2C6822912752890253312%29)

This link is to the LinkedIn discussion of the article, not the article itself.

[Form.Repaint method (Access)Microsoft Docso365devx](https://docs.microsoft.com/en-us/office/vba/api/access.form.repaint)

[Form.Refresh method (Access)Microsoft Docso365devx](https://docs.microsoft.com/en-us/office/vba/api/access.form.refresh)

[Form.Recalc method (Access)Microsoft Docso365devx](https://docs.microsoft.com/en-us/office/vba/api/access.form.recalc)

*Image by [Prashant Sharma](https://pixabay.com/users/yohoprashant-8132018/?utm%5Fsource=link-attribution&utm%5Fmedium=referral&utm%5Fcampaign=image&utm%5Fcontent=3194977) from [Pixabay](https://pixabay.com/?utm%5Fsource=link-attribution&utm%5Fmedium=referral&utm%5Fcampaign=image&utm%5Fcontent=3194977)*