Win 10 64-bit conversion from 32-bit (1 Viewer)

justphilip2003

Registered User.
Local time
Today, 12:16
Joined
Mar 3, 2013
Messages
30
I have a bunch of old Access databases that were written under 32-bit software. I now have a total unfriendly 64-bit system that will not let me use my old code. Sample errant code:
************

Declare
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

************
I would like to know how to resolve these issues while maintaining flexibility of the code working in either 32 0r 64 bit environment. Is this possible? TIA JP. :eek:
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 12:16
Joined
Feb 28, 2001
Messages
27,188
The question isn't whether the box is running 64-bit Windows. The O/S inherently "shells" the 32-bit stuff with a task called SVCHOST.EXE that makes 32-bit apps feel right at home. The question is whether the version of Access that you have installed is 32-bit or 64-bit. If you are running apps developed under 32-bit Access and are now trying to run them under 64-bit Access, that is your problem.

I am unfamiliar with that version of Access that you named. Is that perhaps a typo? When I search for that version of Access, I get an open-access publishing hit but nothing for database utilities.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 18:16
Joined
Feb 19, 2013
Messages
16,614
if converting vba code to work on 64 bit office, the main changes are use of ptrSafe for API calls and converting Longs where necessary - which to convert is down to investigation as to what the Long represents.

See this link for more information

https://msdn.microsoft.com/en-us/library/office/ee691831(v=office.14)

Note that this is to compilation stage. Once a DB compiled, the compiled version will only run in the same bit version environment it was compiled it.
 

isladogs

MVP / VIP
Local time
Today, 18:16
Joined
Jan 14, 2017
Messages
18,227
Following on from the last post, in fact you can compile the database to work in 32-bit or 64-bit by changing declaration code as follows:

Additional items shown in RED

I've had to use code like this for several years as one of my clients uses 64-bit Office on some machines but 32-bit on others.
Thankfully it works without me having to develop 2 versions of the database

Code:
#If Win64 Then
   [COLOR="DarkGreen"] 'Add PtrSafe / LongPtr - required for 64-bit Office[/COLOR]
    Declare [COLOR="Red"]PtrSafe Function[/COLOR] aht_apiGetOpenFileName Lib "comdlg32.dll" _
        Alias "GetOpenFileNameA" (OFN As tagOPENFILENAME) As Boolean

    Declare [COLOR="red"]PtrSafe Function[/COLOR] aht_apiGetSaveFileName Lib "comdlg32.dll" _
        Alias "GetSaveFileNameA" (OFN As tagOPENFILENAME) As Boolean

    Declare [COLOR="red"]PtrSafe Function[/COLOR] CommDlgExtendedError Lib "comdlg32.dll" () As [COLOR="red"]LongPtr[/COLOR]

#Else
    Declare [COLOR="red"]Function[/COLOR] 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

NOTE:

1. You omitted 'Function' in the first declaration - added above

2. If using 64-bit Office, the #Else section will be shown in red as though there is an error. However it still compiles, and is just ignored
 

CJ_London

Super Moderator
Staff member
Local time
Today, 18:16
Joined
Feb 19, 2013
Messages
16,614
@Ridders - is that compiled code (.accde?)

i.e. you compile to .accde and it works in both 64bit and 32bit access environment?

or are you still providing both 32bit and 64bit version of the same db for each environment?
 

isladogs

MVP / VIP
Local time
Today, 18:16
Joined
Jan 14, 2017
Messages
18,227
Hi CJ

I forgot to say this only applies to accdb files as I only rarely convert to accede
However where I do so, it is necessary to save a separate version for use on 64 bit office

To do so I just run the 'combined code' accdb on 64 bit and then save as accde executable. I assume Access just strips out the code not appropriate to the 'bitness' though I may be wrong. Anyway it works which is the main thing
 

CJ_London

Super Moderator
Staff member
Local time
Today, 18:16
Joined
Feb 19, 2013
Messages
16,614
I always compile to .accde as I don't want clients messing with the code.

As you do, I compile the same accdb from two different access versions. Just thought you may have had a workaround:)
 

isladogs

MVP / VIP
Local time
Today, 18:16
Joined
Jan 14, 2017
Messages
18,227
I wish ....
My databases are still largely open source though in practice nobody ever messes with the code
If they did, I would do the same as you!
Not tested whether accdr version will work in both setups though I suspect it will do
 

CJ_London

Super Moderator
Staff member
Local time
Today, 18:16
Joined
Feb 19, 2013
Messages
16,614
some of my clients do. The problem is they then say something no longer works - and it takes time to find out what has stopped working since they don't admit to changing things. So I'd rather not take the chance.

One client knew nothing, but knew a man 'who did' and they thought they would save a tenner by getting him to change something.

For a while I tried just password protecting the code, but they can still change forms/reports - moving controls deleting event calls etc. Although I hide all this stuff they can still get in with a modicum of skill. So .accde it is for me!

.accdr is just a file extension which tells a full version of access to run in runtime mode. The 32/64 bit requirement will still apply
 

isladogs

MVP / VIP
Local time
Today, 18:16
Joined
Jan 14, 2017
Messages
18,227
some of my clients do. The problem is they then say something no longer works - and it takes time to find out what has stopped working since they don't admit to changing things. So I'd rather not take the chance.

Yes I've had the same thing with a so called expert so arranged for the guilty party to have admin rights withdrawn. That fixed the issue.
Mind you I did say I would charge a hefty sum to fix it if the problems recurred!

I also have code which acts as an audit trail so I can 'prove' who did what if needed!

In my databases, standard users cannot see the database window, ribbon or VBE so effectively it comes to the same thing as you
 

justphilip

Registered User.
Local time
Today, 13:16
Joined
Oct 28, 2016
Messages
18
Thanks all for the great responses! To correct my poor typing, I am currently using MS Office 2010 - Access 2010 in I believe 32-bit mode. All of my databases were developed on older platforms going as far back as 1995. The problems occurred in module modOpenSaveFile, code originally written by Ken Getz (Code courtesy of: Microsoft Access 95 How-To Ken Getz and Paul Litwin Waite Group Press, 1996.)

I will study the information and proceed from there. Thanks again to all who responded to my query! JP
 

CJ_London

Super Moderator
Staff member
Local time
Today, 18:16
Joined
Feb 19, 2013
Messages
16,614
Access 2010 in I believe 32-bit mode
easy to check - go to File>Help, you'll see the version and bit type in the About Microsoft Access section
 

justphilip

Registered User.
Local time
Today, 13:16
Joined
Oct 28, 2016
Messages
18
I checked to see what I now have: MS Office Pro | Access version: 14.0.7180.5002 (64-bit). Thanks for the tip! I fixed my module modOpenSaveFile problem.
To tell the truth, this db module was incorporated back around 1997 when I found it on the internet and I've forgotten exactly what it did for me - been away from Access programming far to long! LOL JP
 

Users who are viewing this thread

Top Bottom