Link to home
Start Free TrialLog in
Avatar of J.R. Sitman
J.R. SitmanFlag for United States of America

asked on

Need help converting Access database to run on Access 2016

Can anyone help me fix this error in the code to get it to work with Access 2016?    FYI I am "Not" a programmer so I need basic instructions.
User generated image

ASKER CERTIFIED SOLUTION
Avatar of Daniel Pineault
Daniel Pineault

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of J.R. Sitman

ASKER

I will give it a try
In order to be a bit bulletproof
#If VBA7 Then '64Bit
Private Declare PtrSafe Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
Private Declare PtrSafe Function GetSaveFileName Lib "comdlg32.dll" Alias "GetSaveFileNameA" (pOpenfilename As OPENFILENAME) As Long

#Else    '32bit aka x86
Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
Private Declare Function GetSaveFileName Lib "comdlg32.dll" Alias "GetSaveFileNameA" (pOpenfilename As OPENFILENAME) As Long

#End If

Open in new window


Avatar of Daniel Pineault
Daniel Pineault

Just to explain John's answer, he is using Conditional Compiler Directives

#If VBA7 Then '64Bit

#Else    '32bit aka x86

#End If

Open in new window

this way the program will choose what lines of code (API declarations in this case) based on the condition (VBA7) or not.  This enables you to create code that will work on both 32 and 64-bit versions of Access.

This is fine for accdb, but if you deploy accde, do note you need to compile each bitness separately (32-bit on a 32-bit installation of Access and 64-bit on a 64-bit installation of Access).

Beyond APIs, when changing bitness, you also need to change you ActiveX controls.

You may like to review https://www.devhut.net/2017/04/13/access-x32-vs-x64-compatibility/


Hi,

Unless you need specific option or behavior provided by those 2 API, the Office.FileDialog object replace it nicely.
JR,

<<Unless you need specific option or behavior provided by those 2 API, the Office.FileDialog object replace it nicely. >>

 This is partly what I meant about looking at the software that was making the call (JR had contacted me off-line last night about converting 32 to 64 bit).

Jim.
Thanks to all of you.    I will work on this today.
Thanks