All of a sudden my database is having problems with the function that is suppose to determine the computer user name in W2000.
It's been working fine for a long time and still works on my computer. However, all of a sudden this morning it's not working on other people's computers.
It's saying it's not recognizing the String$ function:
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Declare Function apiGetComputerName Lib "kernel32" Alias _
"GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Function fOSUserName() As String
'Returns the network login name
On Error GoTo ErrorHandler
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 = ""
End If
ExitProcedure:
Exit Function
ErrorHandler:
MsgBox Err.Number & ": " & Err.Description, vbOKOnly + vbExclamation
Resume ExitProcedure
End Function
It's been working fine for a long time and still works on my computer. However, all of a sudden this morning it's not working on other people's computers.
It's saying it's not recognizing the String$ function:
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Declare Function apiGetComputerName Lib "kernel32" Alias _
"GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Function fOSUserName() As String
'Returns the network login name
On Error GoTo ErrorHandler
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 = ""
End If
ExitProcedure:
Exit Function
ErrorHandler:
MsgBox Err.Number & ": " & Err.Description, vbOKOnly + vbExclamation
Resume ExitProcedure
End Function