Link to home
Start Free TrialLog in
Avatar of Taras
TarasFlag for Canada

asked on

MS Access on 32 vs 64 bit and VBA7

I have this part of code to make my Access 2003 32 bit application to work on 64 bit and MS access 2010.

Option Explicit


#If Win64 Then
 
    Declare PtrSafe Function apiGetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As LongLong) As LongLong
#Else
 
    Declare Function apiGetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
#End If

#If VBA7 Then
 
    Private Declare PtrSafe Function apiGetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
#Else
 
    Private Declare Function apiGetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
#End If


I am getting error in part :

#If VBA7 Then
 
    Private Declare PtrSafe Function apiGetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long <<< error line.
Error :Compile Error:
Ambiguous name detected apiGetUserName

How to get rid of this and get this function work in 32 and 64 as on new and old Access.?
ASKER CERTIFIED SOLUTION
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
<<Your problem has nothing to do with conditional compilation.>>

  He's got the same call declared twice and right now, he's running 64 bit in 2010 or higher, so both constants are true.

Jim.
Avatar of Taras

ASKER

Thank you a lot.