# Marked Text Fields

> Insert, find, change, protect and delete marked text fields in TXTextControl with FieldInsert, FieldCurrent, FieldText and FieldNext, and handle field events.

- **Product:** TX Text Control ActiveX
- **Section:** Documentation
- **Kind:** Topic
- **Path:** TX Text Control ActiveX > Document Editor > Marked Text Fields
- **1384 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-activex/document-editor/fields/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-activex/document-editor/fields/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-activex/document-editor/fields/llms-full.txt

---

Marked text fields are ranges of text in a `TXTextControl` that your application can address by number: it changes their text, finds their position, protects them and reacts when users click or edit them. Mail merge fields, hypertext links, bookmarks, page numbers and imported Microsoft Word fields are all built on them.

![The TX Text Control Quote Generator sample with the recipient's address shown as a highlighted marked text field and Address field in the status bar, in the look of TX Text Control 10](https://docs.textcontrol.com/assets/img/tx-text-control-activex/address-field-highlighted.943dea0b.webp)

Read on for how you insert fields and work with them in Visual Basic, and for the pages that cover editing, related data, the special field types and the Visual Basic tutorials.

### How Marked Text Fields Work

A field gets into the text in one of two ways: your code inserts it with the [FieldInsert](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/fieldinsert-method/llms-full.txt) method, or it arrives as part of a document loaded with the [Load](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/load-method/llms-full.txt) method. All communication with fields works through unique numbers, the field identifiers, which [FieldInsert](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/fieldinsert-method/llms-full.txt) returns or which you define.

Before you work with a field, make it the current field by setting the [FieldCurrent](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/fieldcurrent-property/llms-full.txt) property to its identifier. Then you can:

- **Change or read its text** with the [FieldText](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/fieldtext-property/llms-full.txt) property.
- **Delete it** with the [FieldDelete](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/fielddelete-method/llms-full.txt) method.
- **Find its position**, geometrically with [FieldPosX](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/fieldposx-property/llms-full.txt) and [FieldPosY](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/fieldposy-property/llms-full.txt), or as a character position with [FieldStart](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/fieldstart-property/llms-full.txt) and [FieldEnd](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/fieldend-property/llms-full.txt).
- **Get the next field** in the text, or enumerate all fields, with the [FieldNext](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/fieldnext-method/llms-full.txt) method.

### Protect Fields From Users

Two properties restrict what users can do with a field: [FieldChangeable](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/fieldchangeable-property/llms-full.txt) prevents its text from being changed, and [FieldDeleteable](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/fielddeleteable-property/llms-full.txt) prevents it from being deleted. Further attributes that help users edit the text of a field are the subject of [Editing Marked Text Fields](https://docs.textcontrol.com/tx-text-control-activex/document-editor/fields/editing/llms-full.txt).

### Respond to Field Events

`TXTextControl` informs your application about what happens to fields through events:

| Event | Occurs when |
|---|---|
| [FieldClicked](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/fieldclicked-event/llms-full.txt), [FieldDblClicked](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/fielddblclicked-event/llms-full.txt) | The user clicks or double-clicks a field. |
| [FieldEntered](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/fieldentered-event/llms-full.txt), [FieldLeft](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/fieldleft-event/llms-full.txt) | The input position moves into or out of a field. |
| [FieldSetCursor](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/fieldsetcursor-event/llms-full.txt) | The mouse pointer moves over a field. Use it to define the pointer; the default is the up-arrow cursor. |
| [FieldChanged](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/fieldchanged-event/llms-full.txt) | The text of a field has been changed. |
| [FieldCreated](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/fieldcreated-event/llms-full.txt), [FieldDeleted](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/fielddeleted-event/llms-full.txt) | Fields have been created or deleted while text is inserted or deleted with the keyboard or the clipboard. |

### Properties, Methods and Events

Every property, method and event for programming marked text fields is listed in two programming categories of the reference:

- [Text Fields](https://docs.textcontrol.com/tx-text-control-activex/reference/categories/text-fields/llms-full.txt): the `Field` members that every marked text field has.
- [Hypertext Links](https://docs.textcontrol.com/tx-text-control-activex/reference/categories/hypertext-links/llms-full.txt): field types, type-related data and the `Target` members for link targets and bookmarks.

### Find the Right Page

| If you want to | Read |
|---|---|
| Help users type inside or outside a field | [Editing Marked Text Fields](https://docs.textcontrol.com/tx-text-control-activex/document-editor/fields/editing/llms-full.txt) |
| Store a database field name or other data with a field | [Relating Data to a Marked Text Field](https://docs.textcontrol.com/tx-text-control-activex/document-editor/fields/data/llms-full.txt) |
| Insert links, page numbers, highlights or Word fields | [Special Types of Marked Text Fields](https://docs.textcontrol.com/tx-text-control-activex/document-editor/fields/special-types/llms-full.txt) |
| Move code from link target fields to the `Target` members | [Link Targets and Bookmarks](https://docs.textcontrol.com/tx-text-control-activex/document-editor/fields/link-targets-bookmarks/llms-full.txt) |
| Build a Visual Basic application step by step | [Using Marked Text Fields in Visual Basic](https://docs.textcontrol.com/tx-text-control-activex/document-editor/fields/tutorial/llms-full.txt), [Hypertext Links](https://docs.textcontrol.com/tx-text-control-activex/document-editor/fields/hyperlinks/llms-full.txt), [Using Microsoft Word Fields](https://docs.textcontrol.com/tx-text-control-activex/document-editor/fields/microsoft-word/llms-full.txt) |

### Pages in This Section

- [Editing Marked Text Fields](https://docs.textcontrol.com/tx-text-control-activex/document-editor/fields/editing/llms-full.txt): a second input position, caret width and background at the edges of a field.
- [Relating Data to a Marked Text Field](https://docs.textcontrol.com/tx-text-control-activex/document-editor/fields/data/llms-full.txt): strings and numbers stored with a field through `FieldData`.
- [Special Types of Marked Text Fields](https://docs.textcontrol.com/tx-text-control-activex/document-editor/fields/special-types/llms-full.txt): links, page numbers, highlights, topics and Microsoft Word fields.
- [Link Targets and Bookmarks](https://docs.textcontrol.com/tx-text-control-activex/document-editor/fields/link-targets-bookmarks/llms-full.txt): the `Target` members that replace `txFieldLinkTarget` fields.
- [Using Marked Text Fields in Visual Basic](https://docs.textcontrol.com/tx-text-control-activex/document-editor/fields/tutorial/llms-full.txt): a simple example, bookmarks and strings added to fields.
- [Hypertext Links](https://docs.textcontrol.com/tx-text-control-activex/document-editor/fields/hyperlinks/llms-full.txt): inserting links, an insert dialog box, targets and jumps to external targets in four steps.
- [Using Microsoft Word Fields](https://docs.textcontrol.com/tx-text-control-activex/document-editor/fields/microsoft-word/llms-full.txt): classes for the MERGEFIELD and FORMTEXT fields of Word.

---

## In This Section

- [Relating Data to a Marked Text Field](https://docs.textcontrol.com/tx-text-control-activex/document-editor/fields/data/llms-full.txt): Relate strings or numbers such as database field names to marked text fields with FieldData, read them in FieldClicked and keep them when copying or saving.
- [Editing Marked Text Fields](https://docs.textcontrol.com/tx-text-control-activex/document-editor/fields/editing/llms-full.txt): Control typing at the edges of marked text fields with FieldEditAttr: a second input position, caret width, gray background and double-click handling.
- [Hypertext Links](https://docs.textcontrol.com/tx-text-control-activex/document-editor/fields/hyperlinks/llms-full.txt): Insert external and internal hypertext links and targets in Visual Basic 6 with FieldType and TargetInsert, and jump on FieldLinkClicked with TargetGoto.
- [Link Targets and Bookmarks](https://docs.textcontrol.com/tx-text-control-activex/document-editor/fields/link-targets-bookmarks/llms-full.txt): Replace the old txFieldLinkTarget field members with TargetInsert, TargetName, TargetGoto and the other Target members for link targets and bookmarks.
- [Using Microsoft Word Fields](https://docs.textcontrol.com/tx-text-control-activex/document-editor/fields/microsoft-word/llms-full.txt): Wrap the Microsoft Word MERGEFIELD and FORMTEXT fields in Visual Basic 6 classes that read FieldTypeData, edit them in dialog boxes and merge database data.
- [Special Types of Marked Text Fields](https://docs.textcontrol.com/tx-text-control-activex/document-editor/fields/special-types/llms-full.txt): Create hypertext links, page numbers, highlights and topics with FieldType and FieldTypeData, and import MERGEFIELD and form fields from Word and RTF files.
- [Using Marked Text Fields in Visual Basic](https://docs.textcontrol.com/tx-text-control-activex/document-editor/fields/tutorial/llms-full.txt): Insert marked text fields in Visual Basic 6 with FieldInsert, show a pop-up on FieldClicked and build numbered and named bookmarks with FieldData and FieldNext.

---

## Nearby

- **Previous:** [Headers and Footers](https://docs.textcontrol.com/tx-text-control-activex/document-editor/headers-footers/llms-full.txt)
- **Next:** [Editing Marked Text Fields](https://docs.textcontrol.com/tx-text-control-activex/document-editor/fields/editing/llms-full.txt)
