Please help with fOSUserName()

Rob.Mills

Registered User.
Local time
Today, 05:22
Joined
Aug 29, 2002
Messages
871
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
 
This is normally caused by a broken reference. Go to one of the machines that this is occuring on and check the references. If none of the references show as being missing then remove the DAO or ADO reference, close down the reference screen, open the references again and add the DAO or ADO reference back (You can use any reference I choose these because it is easier for me to remember). This will refresh your references and should remove the "Not Recognizing" of the String$ function.
 
Thanks for your response. In fact it does say some references are missing. I think the problem is the network guys setup my computer to have the libraries in a folder called Office10 while most other people's is Office. Know of any way around that?
 
I did end up finding the problem. Turns out that the network guys are slowing upgrading everyone to office xp. Mine was one of the first. So when I put a new copy of the frontend out it was looking for the libraries in the wrong folder for everyone else.

We got it working. Thanks.
 

Users who are viewing this thread

Back
Top Bottom