Network User Name

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I have a acess project 2003 on desktop and Sql 2000 on the server
I'm using Windows NT Integrated Security

I want to capture Network User Name in a text box.

I use the funtion FOSUserName() and User() and WNetGetUser() and the message
is the same -----> #Name?

Thank for your help
 
How exactly are you using those functions? Are you assigning the value to
the text box through VBA code, or have you simply set the field's Control
Source to =fOSUserName()?

What happens if you try ?fOSUserName in the immediate window?
 
In the text box i put = fOSUserName() and

I create a module name fOSUserName with this:

Option Compare Database

'******************** Code Start **************************
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
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
'******************** Code End **************************
 
in message:
In the text box i put = fOSUserName() and

I create a module name fOSUserName with this:

Fernando, did you name the module *itself* FOSUserName??
If so, that is the problem. You cannot name any module with
the same name as a function or a sub. Change the name of
the module itself to something like basOSUserName so
Access will not get confused.
 
Fernando, did you name the module *itself* FOSUserName??

Jeff

He said exactly that in his post.

Cheers
Van
 
Jeff Conrad said:
in message:


We cannot forget Doug either!

Doug who? <g>

I typically only get to the groups once a day, so I might have caught it
today if you show-offs hadn't jumped in! <g>
 
Back
Top