And I finally found the solution:
Code:
Option Compare Database
Option Explicit
#If VBA7 Then
Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As LongPtr)
#Else
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
#End If
Public Sub mySleep(Optional Seconds As Double = 1, Optional AllowDoEvents As Boolean = True)
' this function will break up seconds into quarters of a second
Dim SecFrac As Double
SecFrac = 0
While SecFrac < Seconds
Sleep 250
If AllowDoEvents Then DoEvents
SecFrac = SecFrac + 0.25
Wend
End Sub