Access 2010
I have an application that has been running on a Win XP SP3 (32 bit) machine for years. I'm trying to get it to run on a new Win 7 64 bit machine. I copied all the files, linked whatever tables I could (one was not in an Access format, but that's a whole other story) and I get the following compile error (see screenshot).
How do I fix this so it runs on a 64 bit machine?
Thanks in advance.
Transfer from 32 bit to 64 bit machine
-
- 3StarLounger
- Posts: 390
- Joined: 26 Jan 2010, 16:02
- Location: Las Vegas, NV
Transfer from 32 bit to 64 bit machine
You do not have the required permissions to view the files attached to this post.
Carol W.
-
- 3StarLounger
- Posts: 390
- Joined: 26 Jan 2010, 16:02
- Location: Las Vegas, NV
Re: Transfer from 32 bit to 64 bit machine
Please ignore. I found the answer myself (with the help of Google).
Private Declare PtrSafe Function ....
Thanks anyway.
Private Declare PtrSafe Function ....
Thanks anyway.
Carol W.
-
- Administrator
- Posts: 78530
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Transfer from 32 bit to 64 bit machine
Jan Karel Pieterse has written an article about this: Excel: Declaring API functions in 64 bit Office. Although it's for Excel, it applies to Access too. The article and the links explain what you'd need to change.
The definition of OPENFILENAME and the declarations would become
This will not work in Access 2007 or before. For compatibility, you can use this:
The definition of OPENFILENAME and the declarations would become
Code: Select all
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 Long
lpfnHook As LongPtr
lpTemplateName As String
End Type
Private Declare PtrSafe Function GetOpenFileName Lib "comdlg32.dll" _
Alias "GetOpenFileNameA" (OFN As OPENFILENAME) As Boolean
Declare PtrSafe Function GetSaveFileName Lib "comdlg32.dll" _
Alias "GetSaveFileNameA" (OFN As OPENFILENAME) As Boolean
Code: Select all
#If VBA7 Then
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 Long
lpfnHook As LongPtr
lpTemplateName As String
End Type
Private Declare PtrSafe Function GetOpenFileName Lib "comdlg32.dll" _
Alias "GetOpenFileNameA" (OFN As OPENFILENAME) As Boolean
Declare PtrSafe Function GetSaveFileName Lib "comdlg32.dll" _
Alias "GetSaveFileNameA" (OFN As OPENFILENAME) As Boolean
#Else
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 Declare Function GetOpenFileName Lib "comdlg32.dll" _
Alias "GetOpenFileNameA" (OFN As OPENFILENAME) As Boolean
Private Declare Function GetSaveFileName Lib "comdlg32.dll" _
Alias "GetSaveFileNameA" (OFN As OPENFILENAME) As Boolean
#End If
Best wishes,
Hans
Hans
-
- Administrator
- Posts: 78530
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Transfer from 32 bit to 64 bit machine
Great! But you need a bit more: the definition of OPENFILENAME has to be updated too. And if you want to be able to use the database both in Access 2010 and in earlier versions, you need a special modification. See my previous reply.Carol W. wrote:Please ignore. I found the answer myself (with the help of Google).
Private Declare PtrSafe Function ....
Best wishes,
Hans
Hans
-
- 3StarLounger
- Posts: 390
- Joined: 26 Jan 2010, 16:02
- Location: Las Vegas, NV
Re: Transfer from 32 bit to 64 bit machine
Thank you, Hans. I will look at that article and I will change the definititon of OPENFILENAME.
Both machines now run Access 2010 (I upgraded the 32 bit machine to Office 2010 a little over a month ago) so backward compatibility isn't an issue.
Both machines now run Access 2010 (I upgraded the 32 bit machine to Office 2010 a little over a month ago) so backward compatibility isn't an issue.
Carol W.