Sleep Lib "kernel32" gives 64-bit systems error

change your api declaration to this :

#If VBA7 And Win64 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

For 64bit APIs read this: http://www.jkp-ads.com/articles/apideclarations.asp


The dwMilliseconds parameter is a DWORD, so it will technically be 32bit on a 32bit machine and 64bit on a 64bit machine. Because of this, it requires PtrSafe notation (although technically dwMilliseconds will marshal correctly because it's ByVal... and who wants to wait that long anyway) Change the declaration to this:

#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

Tags:

Ms Access

Vba