I am getting a compile error when trying to open up my database in access

Tanya Rothstein 0 Reputation points
2023-05-10T18:12:25.98+00:00

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 attribute

I have no idea what they want me to do or how to fix it.

Access
Access
A family of Microsoft relational database management systems designed for ease of use.
325 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Vahid Ghafarpour 20,030 Reputation points
    2023-05-10T18:25:06.78+00:00

    The error message you're encountering suggests that the code in your Access project needs to be updated to work properly on 64-bit systems. Microsoft Access uses VBA (Visual Basic for Applications) as its programming language, and the error is specifically related to the "Declare" statements in your code.

    In 64-bit versions of Microsoft Office, including Access, there are some changes in how these Declare statements should be written to ensure compatibility. To resolve this issue, you'll need to make the following modifications to your code:

    1. Open the VBA editor in Access by pressing Alt + F11.
    2. In the VBA editor, navigate to the module or code where the error occurs.
    3. Look for any Declare statements in the code. These are typically used to import functions from external libraries.
    4. For each Declare statement, you need to add the "PtrSafe" attribute at the end of the statement, just before the function name. Example: If you have a Declare statement like this: Declare Function MyFunction Lib "MyLibrary.dll" Alias "MyAlias" (MyArguments) As MyType Update it to: Declare PtrSafe Function MyFunction Lib "MyLibrary.dll" Alias "MyAlias" (MyArguments) As MyType

    By adding the "PtrSafe" attribute, you're indicating to the compiler that the Declare statement is compatible with both 32-bit and 64-bit systems.

    Once you've made the necessary modifications, save the changes and try running your code again. It should now work correctly on 64-bit systems without the compile error.

    1 person found this answer helpful.
    0 comments No comments

  2. Tanay Prasad 2,115 Reputation points
    2023-05-11T07:06:40.99+00:00

    Hi,

    This error occurs because your Access database includes code that is incompatible with 64-bit systems. To fix it, you'll need to update your code to work with 64-bit systems.

    Here are the steps you can take to fix this error:

    1. Open your Access database and go to the Visual Basic Editor.
    2. In the VBE, go to the Debug menu and select Compile.
    3. Check your code for any declarations that include Declare statements, such as Declare Function, Declare Sub, or Declare PtrSafe. These declarations will be needed to modify to work with 64-bit systems.
    4. Modify the declarations to include the PtrSafe keyword.
    5. Save your changes and close the VBE.
    6. Go back to your Access database and try opening it again.

    This should work for you.

    Best Regards.

    0 comments No comments