Declare Functions Issue 32bit to 64 bit

richlocus
StarLounger
Posts: 61
Joined: 03 Oct 2015, 00:30

Declare Functions Issue 32bit to 64 bit

Post by richlocus »

Hello:
I am converting a very old access 2010 application from the 32-bit to the 64-bit version (and mdb to accdb) of Office 2016. Two questions:

1) I cannot find the 2016 option that says "Always default to DAO (never ADO) when defining Database and Recordset. Do I have to always pre-pend with DAO on these objects, such as Dim db As DAO.Database Dim recIn As DAO.Recordset?

2) I need to convert the following two 32-bit functions so they work on 64-bit. I have attempted to add PrtSafe and LongPtr but so far I'm not getting anywhere.

Here are the original 32-bit functions:

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

Private Type OPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
Flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type

Private mstrFileName As String

Private mblnStatus As Boolean

Thanks for any help!!
Regards,
Rich Locus

User avatar
HansV
Administrator
Posts: 74684
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Declare Functions Issue 32bit to 64 bit

Post by HansV »

1) Do you ever need ADO / ADODB? If not, select Tools > References... and clear the check box for the Microsoft ActiveX Data Objects m.n Library (the number m.n may vary).
Also make sure that the reference to the Microsoft Office 16.0 Access database engine Object Library has a check mark.

2) Like this:

Code: Select all

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
 
Private Type OPENFILENAME
    lStructSize As Long
    hwndOwner As LongPtr
    hInstance As LongPtr
    lpstrFilter As String
    lpstrCustomFilter As String
    nMaxCustFilter As Long
    nFilterIndex As Long
    lpstrFile As String
    nMaxFile As Long
    lpstrFileTitle As String
    nMaxFileTitle As Long
    lpstrInitialDir As String
    lpstrTitle As String
    flags As Long
    nFileOffset As Integer
    nFileExtension As Integer
    lpstrDefExt As String
    lCustData As LongPtr
    lpfnHook As LongPtr
    lpTemplateName As String
End Type
P.S. Recent versions of Access have a built-in FileDialog object.
Regards,
Hans

richlocus
StarLounger
Posts: 61
Joined: 03 Oct 2015, 00:30

Re: Declare Functions Issue 32bit to 64 bit

Post by richlocus »

Thank you Hans! I will keep moving forward.