'MS Access compile error when running on a different PC

I have an Access database that is located in my Google Drive folder hierarchy, with the Google Drive Windows 10 app synchronising with my Google cloud storage.

I've managed to muck something up.

I used to be able to open the same file (separately) on 2 PCs and let the app synchronise changes in the cloud.

But now, the Access database application runs fine on one PC, but gives an error of

"there was an error compiling this function" when the autoexec macro runs.

looking at the code - the syntax error is in this declaration (which used to be fine)

Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Macros also will not run unless I enable all macros in the trust centre settings.

I have added the containing folder to the trusted folders, but still it persists.

If I copy the accdb file to my documents folder on the problematic PC it misbehaves there too.

Both PCs have are running Windows 10 and Office 365. All patching up to date I think.

It has me baffled.

Any help greatly appreciated.



Solution 1:[1]

I installed the 64 bit version of Office on the other PC and changed the declaration to:

#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

Everything is working now.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 niton