我添加了一个函数来获取Active Directory用户登录,用于使用 VBA 的 Access DB,但我不确定为什么我没有在 Expression Builder 中看到我的函数
我在这个问题中定义了类似的函数,但在表达式生成器中看不到该函数。我打算使用这个函数在我的表单上填充一个不可见的 txtBox 并将其记录到数据库中。
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