Richedit creating data merge fields

Hi,

I am trying to add a set of merge fields to a FMCRichEditor, in this case an address. However the line breaks keep getting added to the end of the merge fields and not in the sequences that they been inserted.the fields come out like this followed by the line breaks....

<><><> <> <>

InsertLineBreak by itself works fine, I'm obviously missing something.

Thanks.

procedure TForm10.Button1Click(Sender: TObject);
var
  LB: TLineBreakElement;
  TE: TTextElement;
begin
  RichEditor.BeginUpdate;

  LB := RichEditor.InsertLineBreak;
  TE := RichEditor.InsertText('Address1');
  TE.MergeRef := 'Address1';

  LB := RichEditor.InsertLineBreak;
  TE := RichEditor.InsertText('Address2');
  TE.MergeRef := 'Address2';

  LB := RichEditor.InsertLineBreak;
  TE := RichEditor.InsertText('Suburb');
  TE.MergeRef := 'Suburb';

  TE := RichEditor.InsertText(' ');
  TE := RichEditor.InsertText('State');
  TE.MergeRef := 'State';

  TE := RichEditor.InsertText(' ');
  TE := RichEditor.InsertText('Postcode');
  TE.MergeRef := 'Postcode';

  LB := RichEditor.InsertLineBreak;

  RichEditor.EndUpdate;
end;

If you want to append at the end of text, first set the caret to the end with

TMSFNCRichEditor.SetCaret(cpEndDoc);