Error 32 bit Function in 64 bit environment (1 Viewer)

justphilip

Registered User.
Local time
Today, 02:03
Joined
Oct 28, 2016
Messages
18
I recently replaced my PC to one with MS Win 10 Pro (64 bit environment) o/s. I developed this DB over the last 10 - 15 years and I'm not a sharp techie!

My Access DB drop down menus are now giving me error messages; see attachments (name mistypes 33 ==> 32)!

How to fix these function errors - is it a simple name change for the "comdlg32.dll" to "comdlg64.dll"? TIA JP
 

Attachments

  • 33 bit function error in 64 bit enviroment 2.jpg
    33 bit function error in 64 bit enviroment 2.jpg
    51.3 KB · Views: 392
  • 33 bit function error in 64 bit enviroment.jpg
    33 bit function error in 64 bit enviroment.jpg
    50.5 KB · Views: 341

Ranman256

Well-known member
Local time
Today, 02:03
Joined
Apr 9, 2015
Messages
4,339
Declare BOTH versions using PTRSAFE

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
 

justphilip

Registered User.
Local time
Today, 02:03
Joined
Oct 28, 2016
Messages
18
Thanks for the responses. I should have mention that I am using Office 2010 Pro and that this problem first manifested itself when I restored my software to the new PC & Win 2010 Pro; prior to that instant the Office 2010 Pro functioned as expected.

The errant code was developed by Ken Getz and sadly, I am not familiar with declare statement nor the # construct. Does it matter where I place the new code; right after the “Option Explicit” statement? Do I place it in every occurrence of drop down menu logic? Or perhaps in a Form open logic?

#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


TIA JP
 

RuralGuy

AWF VIP
Local time
Today, 00:03
Joined
Jul 2, 2005
Messages
13,826
Put the supplied code right where your existing highlighted code is located.
 

justphilip

Registered User.
Local time
Today, 02:03
Joined
Oct 28, 2016
Messages
18
Still getting compile error: The code in this project must be updated for use on 64-bit systems. Please review & update Declare statements and then mark them with the PtdSafe attribute. The code is contained in module modOpenSavefile:

' Code courtesy of:
' Microsoft Access 95 How-To
' Ken Getz and Paul Litwin
' Waite Group Press, 1996

Type tagOPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
strFilter As String
strCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
strFile As String
nMaxFile As Long
strFileTitle As String
nMaxFileTitle As Long
strInitialDir As String
strTitle As String
Flags As Long
nFileOffset As Integer
nFileExtension As Integer
strDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type

#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 <<<<<<<red from here
#End If

Declare Function aht_apiGetOpenFileName Lib "comdlg32.dll" _
Alias "GetOpenFileNameA" (OFN As tagOPENFILENAME) As Boolean

Declare Function aht_apiGetSaveFileName Lib "comdlg32.dll" _
Alias "GetSaveFileNameA" (OFN As tagOPENFILENAME) As Boolean
Declare Function CommDlgExtendedError Lib "comdlg32.dll" () As Long  <<<<<<to here

Global Const ahtOFN_READONLY = &H1
Global Const ahtOFN_OVERWRITEPROMPT = &H2
 

sneuberg

AWF VIP
Local time
Yesterday, 23:03
Joined
Oct 17, 2014
Messages
3,506
I believe the code that Ranman256 post was just offered as an example not to be added to your code. If you just google PtrSafe and start reading I think you'll find that converting these is not a trivial task. Whether a type should be change to LongPtr or LongLong seems to depend on knowing the details of the API. But you may have caught a break. This web page has the declarations for GetOpenFileName set up for you. I'd try that and you could probably use that as a model for the GetSaveFileName declaration.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 01:03
Joined
Feb 28, 2001
Messages
27,140
this problem first manifested itself when I restored my software to the new PC & Win 2010 Pro

Literally restored? Or (more likely) went back to the distribution kit and re-installed everything? Because the problem with Office kits after 2007 i.e. starting with 2010 version, is that the default installation changed from 32-bit flavor to 64-bit flavor, so if you just do the default installation, you get the big guy. The moment you do that, you run into the double-barreled problem of having to update all the library calls with PtrSafe - AND not all of the libraries that are usable with 32-bit Office are the same names for the 64-bit Office, so you'll end up with broken references. If the names change, the references end up "MISSING" in the Tools >> References menu item from a VBA code window.
 

RuralGuy

AWF VIP
Local time
Today, 00:03
Joined
Jul 2, 2005
Messages
13,826
I would say it is time to ReInstall Access on this computer.
 

justphilip

Registered User.
Local time
Today, 02:03
Joined
Oct 28, 2016
Messages
18
How does one define success? I made the following changes in global module "modOpenSaveFile" and it works for 64-bit platform but the old 32-bit logic( in #else clause) is still red - compiler error. The previous run errors have not reoccurred again!

#if Win64 then
Declare PtrSafe Function aht_apiGetOpenFileName Lib "comdlg32.dll" _
Alias "GetOpenFileNameA" (OFN As tagOPENFILENAME) As Boolean
Declare PtrSafe Function aht_apiGetSaveFileName Lib "comdlg32.dll" _
Alias "GetSaveFileNameA" (OFN As tagOPENFILENAME) As Boolean
Declare PtrSafe Function CommDlgExtendedError Lib "comdlg32.dll" () As Long
#else
Declare Function aht_apiGetOpenFileName Lib "comdlg32.dll" _
Alias "GetOpenFileNameA" (OFN As tagOPENFILENAME) As Boolean
Declare Function aht_apiGetSaveFileName Lib "comdlg32.dll" _
Alias "GetSaveFileNameA" (OFN As tagOPENFILENAME) As Boolean
Declare Function CommDlgExtendedError Lib "comdlg32.dll" () As Long
#end if


I am stuck on what to do with the remainder of the logic! TIA
 

RuralGuy

AWF VIP
Local time
Today, 00:03
Joined
Jul 2, 2005
Messages
13,826
Look at my Post #7 and let us know what version of Access you are running, please.
 

justphilip

Registered User.
Local time
Today, 02:03
Joined
Oct 28, 2016
Messages
18
I am definitely running the 64-bit Office Pro with Access at 14.0.7173.5000 (64-bit)
 

sneuberg

AWF VIP
Local time
Yesterday, 23:03
Joined
Oct 17, 2014
Messages
3,506
Why aren't you reinstalling the 32 bit version? There does seem to be much advantage to the 64 bit Office.
 

justphilip

Registered User.
Local time
Today, 02:03
Joined
Oct 28, 2016
Messages
18
I am a 77 year non techie who had this software installed, being ignorant of the Access consequences, I opted for 64-bit. I started this Access program under Win 95 and have progressed through all of the software changes to the present time.

Then there are the possible pit falls of reversal in other areas, since I believe I would have to reinstall Office 2010 Pro.

Also this problem does not appear that complicated! Only my ignorance of the new technology that 64-bit brings to bear - learning is the game to be played! Thanks for the comments! JP
 

RuralGuy

AWF VIP
Local time
Today, 00:03
Joined
Jul 2, 2005
Messages
13,826
I'm pretty sure you can uninstall and reinstall MS Access without messing with the rest of Office. Just my $0.02 :D
 

sneuberg

AWF VIP
Local time
Yesterday, 23:03
Joined
Oct 17, 2014
Messages
3,506
I'm pretty sure you can uninstall and reinstall MS Access without messing with the rest of Office. Just my $0.02 :D

Wouldn't having 32 bit Access and 64 bit Excel, Outlook, etc create even worse problems? I'd hate trying to use Automation in that environment.
 

Minty

AWF VIP
Local time
Today, 07:03
Joined
Jul 26, 2013
Messages
10,366
Wouldn't having 32 bit Access and 64 bit Excel, Outlook, etc create even worse problems? I'd hate trying to use Automation in that environment.
Nope - as far as I can tell Automation still works - I develop in 32 bit Access 2010, we have office 2013 , 2016 and installed (not streamed) office 365, and they all seem to work. This is with a 2013 runtime version of access on the end users machines.
 

justphilip

Registered User.
Local time
Today, 02:03
Joined
Oct 28, 2016
Messages
18
Am I done? The #if logic fixed the problems but the #else logic shows up with compiler errors in the 64-bit environment. The #else logic worked in the 32-bit environment, so am I as far as one can go? If not, what topic would be best to research? TIA

#if Win64 then
Declare PtrSafe Function aht_apiGetOpenFileName Lib "comdlg32.dll" _
Alias "GetOpenFileNameA" (OFN As tagOPENFILENAME) As Boolean
Declare PtrSafe Function aht_apiGetSaveFileName Lib "comdlg32.dll" _
Alias "GetSaveFileNameA" (OFN As tagOPENFILENAME) As Boolean
Declare PtrSafe Function CommDlgExtendedError Lib "comdlg32.dll" () As Long
#else
Declare Function aht_apiGetOpenFileName Lib "comdlg32.dll" _
Alias "GetOpenFileNameA" (OFN As tagOPENFILENAME) As Boolean
Declare Function aht_apiGetSaveFileName Lib "comdlg32.dll" _
Alias "GetSaveFileNameA" (OFN As tagOPENFILENAME) As Boolean
Declare Function CommDlgExtendedError Lib "comdlg32.dll" () As Long
#end if
 

Users who are viewing this thread

Top Bottom