Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access 2003 - PtrSafe 2

Status
Not open for further replies.

torquinian

Programmer
Sep 15, 2006
7
GB
I need to alter an Access 2003 system (Running with Access 2000 File Format) to run on a mix of machines and I am by no means an Access expert.

All was fine with my altering the system in Access 2003 on an XP machine and installing it on the customers machines remotely (They are a considerable distance away) until they started to upgrade their machines and their software.

There is now a mix of 32 and 64 bit machines running Access 2003 and the latest version of Access.

On one particular machine when the Access system is started it comes up saying that the code in the project should be updated, saying that the Declare statements should have the PtrSafe attribute applied.

I have looked through the system and there is only one Declare statement in the software:-
Private Declare Sub Sleep Lib "kernel32" (ByVal lngMilliSeconds As Long)
but there are many Private Function statements in the Modules.

I have altered the Declare statement above to:-
#If win64 then
Private Declare Sub Sleep Lib "kernel32" (ByVal lngMilliSeconds As Long)
#else
Private Declare Sub Sleep Lib "kernel32" (ByVal lngMilliSeconds As Long)
#end if
which runs successfully on my machine, but when I put the PrtSafe attribute into the Win64 Declare statement I get an error.

Can anyone tell me if the PrtSafe statement is valid in Access 2003, and if it is how would I use it in the Declare statement above, or if it is not how could I achieve what I am trying to do!
Also, is it just the Declare statement that needs altering or do all the Private Function statements need altering as well?

Thanks for helping!
 
PtrSafe was introduced with VBA7, which first appeared in Office (and therefore Access) 2010

So rather than

#if Win64 then

you might like to consider

#If VBA7 then
 
I have successfully used this code from Daniel Pineault's web page.

Code:
#If VBA7 And Win64 Then
    [COLOR=#4E9A06]'x64 Declarations[/color]
    Private Declare PtrSafe Function apiGetUserName Lib "advapi32.dll" Alias _
            "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
#Else
    [COLOR=#4E9A06]'x32 Declaration[/color]
    Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
            "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
#End If

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
You might like to give Duane a purple star via clicking "great post
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top