PrevField, PrevField()

Syntax

PrevField

PrevField()

Remarks

The PrevField statement selects the previous field, regardless of whether the field is showing its codes or result. PrevField skips over the following fields, which are formatted as hidden text: XE (Index Entry), TA (Table of Authorities Entry), TC (Table of Contents Entry), and RD (Referenced Document).

The PrevField() function behaves the same as the statement and also returns the following values.

Value

Explanation

0 (zero)

If there is no previous field (in other words, if the selection is not moved)

1

If the selection is moved


With field codes displayed, you can use EditFind to go to the previous field of any type, including XE, TA, TC, and RD fields, provided that hidden text is displayed. Simply specify "^d" (the code for a field character) as the text for the .Find argument and 1 for the .Direction argument, as shown in the following instructions:


ViewFieldCodes 1
EditFind .Find = "^d", .Direction = 1, .Format = 1

To find only XE fields, specify "^d XE" as the text to find.

Example

This macro counts the number of fields above the insertion point (excluding XE, TA, TC, and RD fields) and displays the result in a message box:


Sub MAIN
    count = 0
    While PrevField()
        count = count + 1
    Wend
    MsgBox "Fields above the insertion point:" + Str$(count)
End Sub

See Also

NextField