vba from 32bit to 64bits

Ana12322

New member
Local time
Today, 03:03
Joined
Jul 12, 2023
Messages
21
Hello, I have a problem with a file that only works in office 32bits, I need it to work in 64bits, to be able to work with it.

I don't know what to do to make it work anymore. please help.
 
Have you tried looking at the syntax?
I had a quick look and yours does not look like the example here?

Edit: Good discussion also here
 
Last edited:
Yes, I add yes win64, ptrsafe, longptr, but these give me errors, just like I export to .accdb. But it doesn't work for me in 64 bit.
This is after adding the longptr



Captura de pantalla 2023-07-13 093541.png
 
I have never had to mess with 64 bit, and unless you actually need 64 bit Access, it might be better to install 32 bit?

Regardless I spotted at least two non LongPtr where the example shows it is required?

Code:
#If Win64 Then
Declare PtrSafe Function lstrcpy Lib "kernel32" Alias "lstrcpyA" (ByVal lpDestString As LongPtr, ByVal lpSourceString As LongPtr) As Long

#Else

Declare Function lstrcpy Lib "kernel32" Alias "lstrcpyA" (ByVal lpDestString As Any, ByVal lpSourceString As Any) As Long

#End If



' --------------------------------------------------------
' Get any errors during execution of common dialogs
' --------------------------------------------------------
'32-bit Replacement
#If Win64 Then
Declare PtrSafe Function CommDlgExtendedError Lib "comdlg32.dll" () As Long
 
Yes, but when I add to LongPtr I get the error shown in the image.

I need to add it to 64bits, to work it in the company
 

Attachments

  • error long ptr.png
    error long ptr.png
    22.2 KB · Views: 85
  • Captura de pantalla 2023-07-13 093541.png
    Captura de pantalla 2023-07-13 093541.png
    96.7 KB · Views: 76
Yes, I add yes win64, ptrsafe, longptr, but these give me errors, just like I export to .accdb. But it doesn't work for me in 64 bit.
This is after adding the longptr
The error message say "Incompatible data types"?
Then the problem is that you also must use LongPtr for the variables you use for the LongPtr arguments and return values from the API functions.

Re @Gasman's suggestion:
I think, the use of LongPtr for the arguments to lstrcpy is not really required. You can change it, but it will imply a changed behavior of the code.
 
ok I understand, but it keeps giving me the problem that it does not open in access 64bits.

When I click on the search button it doesn't work.
 
I see the problem. You changed the Any type to LongPtr in the 64bit declaration. Change it back to Any and it should work. See image. Edit: Also the lpSourceString As LongPtr should also be As Any as well. Are you sure the overall type of the function must be LongPtr? I would also try going back to Long there as well if you are still having problems.

1689258970348.png
 
I changed it as you indicated, but it still doesn't work.

When I search for it, it stays like this.
 

Attachments

  • Captura de pantalla 2023-07-13 105147.png
    Captura de pantalla 2023-07-13 105147.png
    36.4 KB · Views: 88
  • Captura de pantalla 2023-07-13 104955.png
    Captura de pantalla 2023-07-13 104955.png
    99.8 KB · Views: 84
Yes, and I get this error.

And the search button still doesn't work.
 

Attachments

  • Captura de pantalla 2023-07-13 093541.png
    Captura de pantalla 2023-07-13 093541.png
    96.7 KB · Views: 81
I've checked & it should be:
Code:
Declare PtrSafe Function lstrcpy Lib "kernel32" Alias "lstrcpyA" (ByVal lpDestString As Any, ByVal lpSourceString As Any) As LongPtr

This is how I would do the conditional compilation using #If VBA7 instead of #If Win64:
Code:
#If VBA7 Then
         Declare PtrSafe Function lstrcpy Lib "kernel32" Alias "lstrcpyA" (ByVal lpDestString As Any, ByVal lpSourceString As Any) As LongPtr
#Else
         Declare Function lstrcpy Lib "kernel32" Alias "lstrcpyA" (ByVal lpDestString As Any, ByVal lpSourceString As Any) As Long
#End If

Your last screenshot shows errors on GlobalFree because that is also incorrectly declared for 64-bit. It should be:

Code:
Declare PtrSafe Function GlobalFree Lib "kernel32" Alias "GlobalFree" (ByVal hMem As LongPtr) As LongPtr

If it still errors after that then there are other issues in your file. You need to go through each API and check all of them!
 
Last edited:
Using 7zip, I am unable to unzip your file. Try recreating the zip file again.
1689266540260.png
 
Not sure why Gasman but the file would not extract for me no matter what I used. The new file unzipped just fine though.
 
Everything compiles OK. There's not much I can do to check on anything else as all the tables are linked tables and are not part of the frontend application provided.
 

Users who are viewing this thread

Back
Top Bottom