none
AddressOf function - data type mismatch RRS feed

  • Question

  • Performing a migration from 32 bit to 64 bit Access VBA, Office 2016, and getting data type mismatch for the AddressOf function.  Have tried both Long formats in 64 bit but continue to get the error.  

    Any suggestions are appreciated.

    Friday, March 31, 2017 4:56 PM

All replies

  • Hi Lou,

    Would you mind posting what you have tried so far? Thanks.

    Friday, March 31, 2017 5:28 PM
  • Hi Lou L,

    Running VBA code that was written before the Office 2010 release (VBA version 6 and earlier) on a 64-bit platform can result in errors if the code is not modified to run in 64-bit versions of Office. Errors will result because VBA version 6 and earlier implicitly targets 32-bit platforms and typically contains Declare Statements that call into the Windows API using 32-bit data types for pointers and handles. Because VBA version 6 and earlier does not have a specific data type for pointers or handles, it uses the Long data type, which is a 32-bit 4-byte data type, to reference pointers and handles. Pointers and handles in 64-bit environments are 8-byte 64-bit quantities. These 64-bit quantities cannot be held in 32-bit data types.

    The problem with running legacy VBA code in 64-bit Office is that trying to load 64-bits into a 32-bit data type truncates the 64-bit quantity. This can result in memory overruns, unexpected results in your code, and possible application failure.

    To address this problem and enable VBA code to work correctly in both 32-bit and 64-bit environments, several language features have been added to VBA. The table at the bottom of this document summarizes the new VBA language features. Three important additions are the LongPtr type alias, the LongLong data type, and the PtrSafe keyword.

    for more detailed information, please refer links below.

    64-Bit Visual Basic for Applications Overview

    You must declare the return type explicitly in a VBA macro that you run in a 64-bit environment

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, April 3, 2017 5:50 AM
    Moderator