My database is 32 bit. Sadly, I needed it to be 64 bit. Microsoft has told me that it can be converted over to 64 bit, but gave me directions to ask a forum on how to do it. Anyone have an idea on this?
My database is 32 bit. Sadly, I needed it to be 64 bit. Microsoft has told me that it can be converted over to 64 bit, but gave me directions to ask a forum on how to do it. Anyone have an idea on this?
you can run 32bit in 64.
you can set the definition of functions using the code to use the correct definition to use:
Code:#if Win64 then Declare PtrSafe Function MyMathFunc Lib "User32" (ByVal N As LongLong) As LongLong #else Declare Function MyMathFunc Lib "User32" (ByVal N As Long) As Long #end if
I've always used this version https://msdn.microsoft.com/en-us/vba...trsafe-keyword
not to say that the other wouldn't work. At least the link will shed more light on the subject matter and provide the keyword for further searching if desired.
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.
Phillip Stiefel has done a very good guide to converting from 32-bit to 64-bit at https://codekabinett.com/rdumps.php?...ion-vba-64-bit
I've been trying to understand that article. I'm sure it's excellent. It looks like it was very well researched. I'm still learning VBA and didn't quite understand it. It looks like there is supposed to be a code to make 32 bit work with the 64 bit. I didn't understand the VBA7 and the code to make it work right.
Ranman, where do I put that code? I'm not familiar with the "definitions of functions"
Ranman's code was just an example.
If you post one of the declaration sections from your modules, one of us can convert it to get you started.
This is the one that gives me the error:
'http://support.microsoft.com/kb/888695
Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _
"GetOpenFileNameA" (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
Function LaunchCD(strform As Form, Optional InitialFolder As String = "C:") As String
Dim OpenFile As OPENFILENAME
Dim lReturn As Long
Dim sFilter As String
OpenFile.lStructSize = Len(OpenFile)
OpenFile.hwndOwner = strform.Hwnd
sFilter = "All Files (*.*)" & Chr(0) & "*.*" & Chr(0) & _
"JPEG Files (*.JPG)" & Chr(0) & "*.JPG" & Chr(0)
OpenFile.lpstrFilter = sFilter
OpenFile.nFilterIndex = 1
OpenFile.lpstrFile = String(257, 0)
OpenFile.nMaxFile = Len(OpenFile.lpstrFile) - 1
OpenFile.lpstrFileTitle = OpenFile.lpstrFile
OpenFile.nMaxFileTitle = OpenFile.nMaxFile
OpenFile.lpstrInitialDir = InitialFolder
OpenFile.lpstrTitle = "Select a file using the Common Dialog DLL"
OpenFile.flags = 0
lReturn = GetOpenFileName(OpenFile)
If lReturn = 0 Then
MsgBox "A file was not selected!", vbInformation, _
"Select a file using the Common Dialog DLL"
Else
LaunchCD = Trim(Left(OpenFile.lpstrFile, InStr(1, OpenFile.lpstrFile, vbNullChar) - 1))
End If
End Function
I have that API in several old databases that I no longer use
You convert by using conditional compiling adding PtrSafe and LongPtr instead of Long
:
NOTE:Code:#If VBA7 Then 'use PtrSafe Private Declare PtrSafe Function GetOpenFileName Lib "comdlg32.dll" Alias _ "GetOpenFileNameA" (pOpenfilename As OpenFilename) As Long #ElseIf Win64 Then 'need datatype LongPtr Private Declare PtrSafe Function GetOpenFileName Lib "comdlg32.dll" Alias _ "GetOpenFileNameA" (pOpenfilename As OpenFilename) As LongPtr #Else '32-bit Office Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _ "GetOpenFileNameA" (pOpenfilename As OpenFilename) As Long #End If
1. I also have a variation of this which uses Boolean instead of Long
2. Some authors such as Phillip Stiefel combine the VBA7 & Win64 code into one section
In my databases, no changes were made to the Type declarations and from memory, it works fine (not tested recently)
However be warned that if you use Type MSA_OPENFILENAME code with that API, it doesn't work in 64-bit
Hope that helps
Last edited by isladogs; 07-23-2018 at 02:43 PM. Reason: Modified text
This is a code from Microsoft. I just copied and pasted it. It works fine in 32 bit, doesn't like 64. How do I use the code you wrote to make it work? Do I just put it in front of it? Or do I replace part of it? This is new ground for me.
Your variation worked better than this one?
Just replace the first 2 lines of your code with what I provided and leave everything else as it was.
It should then work in both 32-bit and 64-bit
I don't understand what you've written in post #11
You said that you have your own variation of this code. I was wondering if it worked better.
It's meant to look like that.
The 32-bit code is always shown in red using 64-bit Access.
Both the Boolean and long versions of this code worked equally well ...as far as I can remember.