Share via


ListFieldLookup Object

SharePoint Designer Developer Reference

Contains information about the Lookup field.

Remarks

The ListFieldLookup object allows you to search for information within a Web site based on a specified field. Use ListFields(Index), where Index is the name or ordinal position of a field of type FieldTypeLookup, to return a single ListFieldLookup object.

Use the Add method to add a field of type ListFieldLookup to the ListFields collection.

The following example adds a new field named NewFileLookupField of type FieldTypeLookup to the ListFields collection.

Visual Basic for Applications
Sub CreateLookup()
'Add new Lookup field
    Dim objApp As Application
    Dim objLstFlds As ListFields
    Dim objFldLookup As ListFieldLookup
    Dim strName As String
    Set objApp = Application
    Set objLstFlds = objApp.ActiveWeb.Lists.Item(0).Fields
    strName = "NewFileLookupField"
    'Add new Field of type FieldTypeLookup to list
    objLstFlds.Add Name:=strName, Description:="New Lookup Field", _
                   Type:=FieldTypeLookup
    Set objFldLookup = objLstFlds.Item("NewFileLookupField")
    MsgBox "A new field named " & strName & " was added to the list " & _
           objApp.ActiveWeb.Lists.Item(0).Name & "."
End Sub

See Also