FieldLookup Event

The FieldLookup event occurs when a when user looks up a field on the form.

Syntax

Function FieldLookUp( Form,Name,Value )

Arguments

Form
The form object that contains the field that is being looked up.
Name
The name of the field that is being looked up.
Name
The name of the field that is being looked up.
Value
The value of the field that is being looked up.

Examples

Function FieldLookUp( Form,Name,Value )
   Form.TraceMsg "FieldLookUp"
   Dim rootDSE, domainObject
   Set rootDSE = GetObject("LDAP://RootDSE")
   DomainContainer = rootDSE.Get("defaultNamingContext")
   Set conn = CreateObject("ADODB.Connection")
   conn.Provider = "ADSDSOObject"
   conn.Open "ADs Provider"
   nickname = Value & "*"
   ldapStr = "<LDAP://" & DomainContainer & ">;(& (mailnickname=" & nickname & ")(| (&(objectCategory=person)(objectClass=user)(!(homeMDB=*))(!(msExchHomeServerName=*)))(&(objectCategory=person)(objectClass=user)(|(homeMDB=*)(msExchHomeServerName=*))) ));adspath;subtree"
   Set rs = conn.Execute(ldapStr)
   While Not rs.EOF
      Set oUser = GetObject(rs.Fields(0).Value)
      For Each email In oUser.proxyAddresses
         If InStr(email, "SMTP:") = 1 Or InStr(email, "smtp:") = 1 Then
            Form.Fields.Field(Name).AddListItem Right(email, Len(email) - 5),Right(email, Len(email) - 5)
         End If
      Next
      rs.MoveNext
   Wend
End Function