Access function to return username, not username

Is there a function I can use to return the current user's name to the textbox, not their username - so Joe Bloggs, not jbloggs?

+3


source to share


1 answer


Assuming you have Active Directory installed, you can use the following code taken from Andrey Artemiev's answer here :

Public Function ADtest() As String
  Dim ADSI As Object, UN As Object
  Set ADSI = CreateObject("ADSystemInfo")
  Set UN = GetObject("LDAP://" & ADSI.UserName)
  ADtest = UN.FirstName
  ADtest = ADtest & " " & UN.LastName
  Set UN = Nothing
  Set ADSI = Nothing
End Function

      



(adding an answer here for better visibility, made by the Community Wiki as this is not my answer and I don't want to receive credit)

+4


source







All Articles