Access declare stmt issue moving from Windows 10 to 11

Eileen T 40 Reputation points
2025-09-24T22:44:15.5566667+00:00

Hi,

I have a basic Access database that is erroring on me now that it was updated to Windows 11.

The error message is

Compile Error

The code in this project must be updated for use on 64-bit systems. Please review and update Declare statements and then mark them with the PtrSafe attirbute

Here is the code it is erroring on. This is a business system so I cannot change to 32-bit

I am not VBA savvy so any assistance with what I need to change will be helpful.

Private Declare Function apiShellExecute Lib "shell32.dll" _

                                     Alias "ShellExecuteA" _

                                     (ByVal hWnd As Long, _

                                      ByVal lpOperation As String, _

                                      ByVal lpFile As String, _

                                      ByVal lpParameters As String, _

                                      ByVal lpDirectory As String, _

                                      ByVal nShowCmd As Long) _

                                     As Long
Microsoft 365 and Office | Access | Development
0 comments No comments
{count} votes

Answer accepted by question author
  1. Tom van Stiphout 40,086 Reputation points MVP Volunteer Moderator
    2025-09-24T23:17:05.13+00:00

    If that is your only declaration, change it to:
    Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As LongPtr, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As LongPtr

    Cool thing is: this works for both bitnesses.

    1 person found this answer helpful.
    0 comments No comments

Answer accepted by question author
  1. George Hepworth 22,215 Reputation points Volunteer Moderator
    2025-09-24T23:14:09.3233333+00:00

    When you installed Windows 11, you must have installed the 64 bit version of Office as well.
    The reason for this compile error is that Windows API declarations for the 64 bit version of Access must be updated for that environment.

    It's not complicated to do, but it's more involved than a simple post in a forum.

    I suggest you watch one or more of these videos and apply the modifications explained in them to your API declarations.

    https://youtu.be/m6b5h6rFHcI?si=dtmHnoArZWoXr5pp
    https://youtu.be/B4U9CBgqE_U?si=Pw0UTQu7feTGwUU9

    https://youtu.be/NE-ixCSkEgI?si=deCUwviHj-58dFYr

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Eileen T 40 Reputation points
    2025-09-24T23:35:54.47+00:00

    Thank you. That change did fix the database. wonderful

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.