vba from 32bit to 64bits (1 Viewer)

Ana12322

New member
Local time
Today, 06:21
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.
 

Ana12322

New member
Local time
Today, 06:21
Joined
Jul 12, 2023
Messages
21
The file
 

Attachments

  • 1 PCS Cost Seg Prog 32bit3.mdb
    4.9 MB · Views: 43

Gasman

Enthusiastic Amateur
Local time
Today, 11:21
Joined
Sep 21, 2011
Messages
14,301
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:

Ana12322

New member
Local time
Today, 06:21
Joined
Jul 12, 2023
Messages
21
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
 

Gasman

Enthusiastic Amateur
Local time
Today, 11:21
Joined
Sep 21, 2011
Messages
14,301
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
 

Ana12322

New member
Local time
Today, 06:21
Joined
Jul 12, 2023
Messages
21
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: 41
  • Captura de pantalla 2023-07-13 093541.png
    Captura de pantalla 2023-07-13 093541.png
    96.7 KB · Views: 37

sonic8

AWF VIP
Local time
Today, 12:21
Joined
Oct 27, 2015
Messages
998
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.
 

Ana12322

New member
Local time
Today, 06:21
Joined
Jul 12, 2023
Messages
21
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.
 

Mike Krailo

Well-known member
Local time
Today, 06:21
Joined
Mar 28, 2020
Messages
1,044
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
 

Ana12322

New member
Local time
Today, 06:21
Joined
Jul 12, 2023
Messages
21
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: 45
  • Captura de pantalla 2023-07-13 104955.png
    Captura de pantalla 2023-07-13 104955.png
    99.8 KB · Views: 50

Ana12322

New member
Local time
Today, 06:21
Joined
Jul 12, 2023
Messages
21
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: 41

isladogs

MVP / VIP
Local time
Today, 11:21
Joined
Jan 14, 2017
Messages
18,225
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:

Ana12322

New member
Local time
Today, 06:21
Joined
Jul 12, 2023
Messages
21
Hi, isladogs.

when i add Long prt i get this error.
 

Attachments

  • 1 PCS Cost Seg Prog 32bit3.zip
    947 KB · Views: 46

Mike Krailo

Well-known member
Local time
Today, 06:21
Joined
Mar 28, 2020
Messages
1,044
Using 7zip, I am unable to unzip your file. Try recreating the zip file again.
1689266540260.png
 

Mike Krailo

Well-known member
Local time
Today, 06:21
Joined
Mar 28, 2020
Messages
1,044
Not sure why Gasman but the file would not extract for me no matter what I used. The new file unzipped just fine though.
 

Mike Krailo

Well-known member
Local time
Today, 06:21
Joined
Mar 28, 2020
Messages
1,044
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

Top Bottom