Network User Name

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
 
D

Douglas J. Steele

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?
 
G

Guest

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 **************************
 
J

Jeff Conrad

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.
 
V

Van T. Dinh

Fernando, did you name the module *itself* FOSUserName??

Jeff

He said exactly that in his post.

Cheers
Van
 
D

Douglas J. Steele

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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

user() 1
Retrieving and setting user logon name in a form 2
Update form field 2
Get User Login Name 10
Record UserID in form 8
users track 4
Porting from 2003 to 2007 6
DLookup 2

Top