Solved

Looking for 64bit version of Declare Function GetUserName Lib

Posted on 2014-03-27
2
3,627 Views
Last Modified: 2014-03-28
I am using getusername function to use Windows login for security.  However, when I tried to use the mdb on a 64 bit setup I get the following error msg.

Compile Error

The code in this project must be updated to 64bit systems.  Please review and updatet declare statetments and then mark them with the PtrSafe atribute.

What do I need to do this?
0
Comment
Question by:Karen Schaefer
2 Comments
 
LVL 12

Accepted Solution

by:
pdebaets earned 500 total points
ID: 39961031
Here's the 64-bit definition:

Declare PtrSafe Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Open in new window

To make your db 32 and 64 bit compatible, include a check for the VBA7 compiler directive constant

#if VBA7 then
'* My 64-bit declarations
Declare PtrSafe Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
#else
'* My 32-bit declarations
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
#end if

Open in new window

0
 

Author Closing Comment

by:Karen Schaefer
ID: 39962076
great thanks
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question