Question : MS Access 2000 not able to find advapi32.dll file but it is in the windows/system32 file.

I am running this function and was not having any trouble until my windows and HP had a conflict and now I am having registry problems.  However in a MS Access 2000 I am running this code to get username of the person signed in however I am getting an error on the  strUserName = String$(254, 0)  where the error is cannot find project or library.  I looked in my reference for advapi32.dll to see if it was there or missing however this is no listing of any type that looks like this file.  I tried to browse and add but it would not allow that either.  So how do I get what was working before back to working.

Peg
 


Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
    "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
    strUserName = String$(254, 0)
    lngLen = 255
    lngX = apiGetUserName(strUserName, lngLen)
    If (lngX > 0) Then
        fOSUserName = left$(strUserName, lngLen - 1)
    Else
        fOSUserName = vbNullString
    End If
End Function

Answer : MS Access 2000 not able to find advapi32.dll file but it is in the windows/system32 file.

try, from the references
uncheck any reference (remember the reference)
click ok

go back to the refrences , check the unchecked reference click ok

do a Debug>compile

clear any errors

Random Solutions  
 
programming4us programming4us