32-bit won't run on 64-bit installation (1 Viewer)

ellenr

Registered User.
Local time
Today, 04:45
Joined
Apr 15, 2011
Messages
397
I am running Office 365 32-bit Access. My program's BE is ODBC MySql. The FE won't run when deployed to 64-bit installation (error 7960 syntax). I have attached code supplied to me several years ago by arnelgp that allowed the program to run on 64-bit Access 2013. I would appreciate any help or suggestions!
 

Attachments

  • vba.accdb
    424 KB · Views: 96

Cronk

Registered User.
Local time
Today, 19:45
Joined
Jul 4, 2013
Messages
2,770
Seems to me that the code won't compile, not because of Win64, but rather you have set a requirement for explicit variable declaration, ie
Code:
Option Explicit
in Module 1, but there is no declaration of the variable tdfCurrent as a tableDef object.
 

ellenr

Registered User.
Local time
Today, 04:45
Joined
Apr 15, 2011
Messages
397
How and where do I declare variable tdfCurrent as a tableDef object? I believe tdfTableDef is dimmed as Variant before it is referenced in each function. This program runs properly on all 32-bit installations--only the 64-bit installations fail. Also, users without full Access installed are able to run on AccessRuntime without a problem.

I am attaching all current modules. I previously attached arnelgp's solution from several years ago, but realized there have been additions to Module1 since then.

Thanks!
 

Attachments

  • vba1.accdb
    460 KB · Views: 102

theDBguy

I’m here to help
Staff member
Local time
Today, 01:45
Joined
Oct 29, 2018
Messages
21,358
Hi ellen. What is actually happening when you try to run the application in a 64-bit Office machine? Do you get any error message?
 

ellenr

Registered User.
Local time
Today, 04:45
Joined
Apr 15, 2011
Messages
397
It apparently bombs with error 7960 (syntax). The distant user hasn't exhibited the ability to send a screen shot. I am currently in the process of uninstalling Office 2003 32-bit from an old laptop and hope to install 64-bit Access so I can see for myself what is going on. I am blown away by how much faster my current computers are compared to the old Dell! If MS will tell me how to install 64-bit I should have some more descriptions of the problem.
 

isladogs

MVP / VIP
Local time
Today, 08:45
Joined
Jan 14, 2017
Messages
18,186
I'm not sure which modules Arnel helped you with, but using #If Win64 isn't needed which you have in basBrowse & Module1.
Module FTP_Functions still needs conversion

Rather than react to each error without a clear understanding of API conversions, I suggest you research the correct approach
The following should help
1. Read the article by Phillip Stiefel at https://codekabinett.com/rdumps.php?...ion-vba-64-bit
2. download the Windows API Viewer by Ron de Bruin from https://www.rondebruin.nl/win/dennis...sapiviewer.htm
That includes both 32-bit and 64-bit versions of most APIs.

As well as adding PtrSafe for all 64-bit declarations you must convert pointers/handles such as hWnd to LongPtr.
Don't forget to review those in Type code blocks

NOTE:
If all of your users are on A2010 or later (32/64-bit), no conditional compilation is needed
Just use PtrSafe on all declarations together with LongPtr where needed

Otherwise use
Code:
#If VBA7 Then 
...APIs with PtrSafe & LongPtr (where needed)
#Else
...original APIs 
#End If
 

ellenr

Registered User.
Local time
Today, 04:45
Joined
Apr 15, 2011
Messages
397
Isladogs, I actually have it running, thanks to you! It is working on both 32 and 64-bit machines. I have one problem remaining, however. When I compile in 64-bit setting, the following errs:
Code:
Sub ShowError()
   Dim lErr As Long, sErr As String, lenBuf As Long
   'get the required buffer size
   InternetGetLastResponseInfo lErr, sErr, lenBuf  ' lenBuf    ByRef Argument type Mismatch
   'create a buffer
   sErr = String(lenBuf, 0)
   'retrieve the last response info
   InternetGetLastResponseInfo lErr, sErr, lenBuf
   'show the last response info
   MsgBox "Last Server Response : " + sErr, vbOKOnly + vbCritical
End Sub

It doesn't like lenBuf and I can't find another reference defining it. When I compile the module in 32-bit, it doesn't err.
 

isladogs

MVP / VIP
Local time
Today, 08:45
Joined
Jan 14, 2017
Messages
18,186
Can you upload your latest version so I can see how you updated the APIs including that one.
Also include some code which makes use of ShowError as its not something I've ever used or in fact seen before
 

ellenr

Registered User.
Local time
Today, 04:45
Joined
Apr 15, 2011
Messages
397
isladogs, I have attached current modules. The ShowError sub is called in Function FTPGet. I can find no other reference. As you may surmise, the FTP_Functions module was something I found online several years ago--it worked perfectly without my having to pick it apart and totally understand. Buttons call these functions and allow the user to upload, download and delete files on the organization's website. I don't do this for a living, and I am beginning to be sorry I volunteered for this! Am learning a lot, though.

I appreciate your taking a look at how I updated APIs--I was mainly guessing at most changes, and did my best to change long to longptr in the calling code. I was amazed that it all seemed to run correctly on my first try. Hope I found all of the affected routines in my tests.

Hope they have this website working smoothly again--haven't been able to access it consistently recently.

Thanks again for all of your input and help!
 

Attachments

  • vba2.accdb
    864 KB · Views: 111

isladogs

MVP / VIP
Local time
Today, 08:45
Joined
Jan 14, 2017
Messages
18,186
The site owner is working on the problems but I don't think they're fixed yet.

Its possible to convert APIs so that they application compiles but that doesn't necessarily mean everything works as it should

I can have a look but in order to test it I need context i.e. code that uses these declarations and related code

I'd already found the ShowError sub and the related API declaration.
What I wanted to know is what that ShowError sub is used for so I can hopefully test it.
Do you have other code in your app which calls it?
If not then perhaps get rid of it completely
 

isladogs

MVP / VIP
Local time
Today, 08:45
Joined
Jan 14, 2017
Messages
18,186
I've spent almost an hour looking at this but am hampered by having no means of testing the APIs in use with the rest of your code.

Also my 64-bit machine is currently running a Windows update so I can't check the code changes do compile correctly ...and remember even if the code compiles it doesn't necessarily mean it will work

So bearing in mind I've not tested any of this in a real app, here are some initial comments:
1. Module basBrowse
I gave up using GetOpenFileName & GetSaveFileName when I first started working with 64-bit back in 2012 or so.
At the time I had major problems getting them to work (partly through inexperience with 64-bit) and due to time constraints scrapped all code using them. I moved over to using the built in FileDialog code which requires no APIs and works in both bitnesses. Recommend you do so also

For your code Private Type udtFileName, the API FileViewer shows similar code under Type OpenFileName
According to that it should be lCustData As LongPtr - otherwise it looks OK ...but remember I haven't tested it!

If you've got it to work, that's excellent but if not I would suggest you do the same as me & use FileDialog

I only use APIs where there is no alternative or where they offer a significant advantage over other methods.
For example using an API to get the user name or computer name is pointless though many people still do so
In contrast, copying files using apiFileCopy is several orders of magnitude faster than other methods built into Office so I do use that.

2. Module1
You hadn't updated this
I've simplified the conditional formatting scrapping the unnecessary #If Win64 blocks
As previously stated, if all users are running A2010 or later scrap all conditional compilation and just use the code in #If VBA7 code blocks

3. FTP_Functions
Lots of things I can't check here as I can't find the APIs.
It may be the API code is out of date as FTP is fairly old technology now
I don't use FTP so am unable to test anyway. What do you still need FTP for?

Anyhow I've made lots of comments of possible alternatives to most of the APIs. I don't know if those will work for you

I think your ShowError issue is inconsistency between datatypes for LenBuf and lpdwErrorBufferLength in API InternetGetLastResponseInfo.
Either both should be Long or both LongPtr

My alterations attached. Good luck
 

Attachments

  • vba3-CR.zip
    89.6 KB · Views: 97

ellenr

Registered User.
Local time
Today, 04:45
Joined
Apr 15, 2011
Messages
397
isladogs, I am just now back into this. I am attaching an another copy of the modules, this one containing the only form that uses the FTP functions so you can see what I am doing. I have not incorporated your changes. If you need anything else, let me know. If you would point me toward FileDialog info, I would love to get rid of the APIs. What could I substitute for the FTP routines?

I will now go through your suggested changes and I thank you!
 

Attachments

  • vba2.accdb
    952 KB · Views: 99

isladogs

MVP / VIP
Local time
Today, 08:45
Joined
Jan 14, 2017
Messages
18,186
I don't have any more time tonight so will leave you to check what I uploaded.

Do a forum or web search for FileDialog. The code is widely used and easy to understand. Here's another thread on the same topic I answered recently
https://www.access-programmers.co.uk/forums/showthread.php?t=308879&highlight=Filedialog

I haven't used FTP in at least 10 years and can't therefore advise you.
Hopefully someone else will be better informed than me
 

ellenr

Registered User.
Local time
Today, 04:45
Joined
Apr 15, 2011
Messages
397
isladogs, your link to mendipdatasystems looks interesting--will get to it when I can. Meanwhile, my main computer got a virus that removed my user accounts, so I couldn't log in. Have spent two days trying to get it restored. I have Acronis full backups, so with a little help from them I have faith that I will get back to business. What a pain! On my 64-bit laptop I have made some progress incorporating your suggested changes. As soon as my houseguests leave and I get back my other computer, I will have a couple of questions about FileDialog. For the moment, the API's are working--thank you!
 

isladogs

MVP / VIP
Local time
Today, 08:45
Joined
Jan 14, 2017
Messages
18,186
Last edited:

Users who are viewing this thread

Top Bottom