We help IT Professionals succeed at work.

Access 32 bit to 64 bit

We are moving to Access 2019 64 bit from Access 2016 32 bit.  I am having problems updating this code to make it 64 bit compatible.  Thanks for your help.  

Option Compare Database
Option Explicit
Private Declare Function GetComputerNameA Lib "kernel32" (ByVal lpBuffer As String, nSize As Long) As Long
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Public Function GetComputerName() As String
'On Error GoTo Err_GetComputerName
Dim Username As String * 255
Call GetComputerNameA(Username, 255)
GetComputerName = Left$(Username, InStr(Username, Chr$(0)) - 1)

    Exit Function

        MsgBox Err.Description
        Resume Exit_GetComputerName

End Function

Public Function GetCurrentUserName() As String
'On Error GoTo Err_GetCurrentUserName
 Dim lpBuff As String * 25
 Dim ret As Long, Username As String
   ret = GetUserName(lpBuff, 25)
   Username = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)
   GetCurrentUserName = Username & ""

    Exit Function

        MsgBox Err.Description
        Resume Exit_GetCurrentUserName
End Function
Watch Question

John TsioumprisSoftware & Systems Engineer
Distinguished Expert 2019

John TsioumprisSoftware & Systems Engineer
Distinguished Expert 2019

President / Owner
Fellow 2019
Most Valuable Expert 2017
See this old thread:


 which also has some links to help with other 32 to 64 bit conversions.

Mark EdwardsChief Technology Officer

I'm assuming that you have Access apps created in 32-bit Access and you need to re-code them to use 64-bit Access/Office and 64-bit Windows on ALL your uses of your app.  Once you've made your code changes, you aren't going to try to get it to work on any 32-bit Access/Office machines, right?

If you are, you'll need conditional compilation to separate the 64-bit only code from the 32-bit only code.