I added a function to get the Active Directory user login, for an Access DB using VBA, but I'm not sure why I don't see my function listed in the Expression Builder
I defined the functions like in this question but I can not see the function in the Expression Builder. I plan to use this function to fill an invisible txtBox on my form and log it into db.
Public Function GetUser(Optional whatpart = "username")
Dim returnthis As String
If whatpart = "username" Then GetUser = Environ("USERNAME"): Exit Function
Set objSysInfo = CreateObject("ADSystemInfo")
Set objUser = GetObject("LDAP://" & objSysInfo.USERNAME)
Select Case whatpart
Case "fullname": returnthis = objUser.FullName
Case "firstname", "givenname": returnthis = objUser.givenName
Case "lastname": returnthis = objUser.LastName
Case Else: returnthis = Environ("USERNAME")
End Select
GetUser = returnthis
End Function