dataFld Property

Sets or returns a String that represents the name of the field in a data source, as specified by the dataSrc property, to which to bind to the specified object. Corresponds to the dataFld attribute for an element.

expression.dataFld

*expression   * Required. An expression that returns one of the objects in the Applies To list.

Example

This example function adds a data source and data field information to the specified form element in the specified form. Use the CallAddDataSource subroutine below to call this function.

Function AddDataSource(strFormName As String, strElementID As String, _
    strDataSource As String, strDataField As String) As Boolean

    Dim objDoc As FPHTMLDocument
    Dim objForm As FPHTMLFormElement
    Dim objTextBox As FPHTMLInputTextElement
    Dim intCounter As Integer

    On Error GoTo AddDataSourceError

    ActiveDocument.body.insertAdjacentHTML where:="afterbegin", _
        HTML:="<form method=""POST"" id=""" & strFormName & """>" & _
        "<input type=""text"" id=""FavoriteIceCream"" size=""20""></form>"

    Set objDoc = ActiveDocument
    Set objForm = objDoc.forms(strFormName)

    For intCounter = 0 To objForm.elements.Length
        If objForm.elements(intCounter).Id = strElementID Then
            Set objTextBox = objForm.elements(intCounter)
            With objTextBox
                .dataSrc = strDataSource
                .dataFld = strDataField
            End With
            AddDataSource = True
            Exit For
        Else
            AddDataSource = False
        End If
    Next

Exit Function

AddDataSourceError:
    AddDataSource = False
End Function

This example calls the AddDataSource function above. In the following example, the FavoriteIceCream input text box form element is bound to the IceCreamFlavor field contained in the data source object with an ID of Customer.

Sub CallAddDataSource()
    
    Dim blnResponse As Boolean
    
    blnResponse = AddDataSource(strFormName:="NewCustomer", _
        strElementID:="FavoriteIceCream", strDataSource:="Customer", _
        strDataField:="IceCreamFlavor")
    
    If blnResponse = True Then
        MsgBox "Success!  You've just added new data source information."
    Else
        MsgBox "Unable to add the new data source information."
    End If
    
End Sub

Applies to | FPHTMLAnchorElement Object | FPHTMLButtonElement Object | FPHTMLDivElement Object | FPHTMLDivPosition Object | FPHTMLFrameElement Object | FPHTMLIFrame Object | FPHTMLImg Object | FPHTMLInputTextElement Object | FPHTMLLabelElement Object | FPHTMLMarqueeElement Object | FPHTMLObjectElement Object | FPHTMLOptionElement Object | FPHTMLSelectElement Object | FPHTMLSpanElement Object | FPHTMLSpanFlow Object | FPHTMLTable Object | FPHTMLTextAreaElement Object | IHTMLDatabinding Object