Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please Explain Environ («environmentstring») 1

Status
Not open for further replies.

priac

Technical User
Feb 8, 2002
47
US
I am told that environ will give me the network login of the person accessing the program. I am not a programmer and need help. I put "=Environ («environmentstring»)" as a default value in one of the tables. What do I need to enter for («environmentstring») ?
 
create a module mile you create a table in the database window

copy this piece of code in the module and save it and close it

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

Public 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


now in the defaultvalue you put this fsousername() this will give you the username you use to login to the network (domain) "What a wonderfull world" - Louis armstrong
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top