IncludeField Method for LCFieldlist

This method includes an existing individual field in a fieldlist.

Defined In

LCFieldlist

Syntax

Call fldLstRecord. IncludeField (index, field, fieldName)

Parameters

Parameter

Description

index

Long, in the range 1 to (fldLst.FieldCount+1). Position within fldLstRecord to insert the field. You can insert the field into the middle of the list without overwriting another field.

field

LCField. The new field.

fieldName

String. The name of the new field.

Example

Option Public
Option Explicit
Uselsx "*lsxlc" 
Sub Initialize
  Dim fldLstRecord As New LCFieldList
  Dim ref As LCField
  Dim text As String
  ' There are a number of ways to build a fieldlist
  ' Append will add a field to a list given a type
  Set ref = FldLstRecord.Append ("ACCOUNTMANAGER", LCTYPE_INT)
  Set ref = FldLstRecord.Append ("COMPANYID", LCTYPE_INT)
  ' Insert is like Append but the position
  ' within the fieldlist must be specified
  Set ref = FldLstRecord.Insert (1, "COMPANYADDRESS", LCTYPE_TEXT)
  ' CopyField will add a field to a list
  ' using an existing field as a template
  Set ref = FldLstRecord.CopyField (1, fld, "CONTACTNAME")
  ' IncludeField will add an existing field to a list,
  ' making it part of the list. in this case, 'fld'
  ' becomes a reference into the fieldlist
  Dim fld As New LCField (LCTYPE_TEXT)
  fld.Flags = LCFIELDF_KEY
  fld.Flags = 0
  Call FldLstRecord.IncludeField (3, fld, "COMPANYCITY")
  text = ""
  Forall fieldname In FldLstRecord.Names
    If Text = "" Then text = fieldname Else text = text + ", " + fieldname
  End Forall
  Print "The field list looks like: " & text
End Sub

Example Output

The field list looks like: 
CONTACTNAME, COMPANYADDRESS, COMPANYCITY, ACCOUNTMANAGER, COMPANYID