Board index » delphi » append to memo(blob field)

append to memo(blob field)

D4, BDE5.x
How can I append text or rtf text to an memo field from program without
using a memo field.

eg Table1MEMO1.Value:= Table1MEMO1.Value+Edit1.Text; // this does not work

Thanks Helmut

 

Re:append to memo(blob field)


one way that works for me is:
    table1memo1.loadfromfile('c:\data.txt');

John Bradbury

Quote
Helmut wrote in message <769rv1$o...@forums.borland.com>...
>D4, BDE5.x
>How can I append text or rtf text to an memo field from program without
>using a memo field.

>eg Table1MEMO1.Value:= Table1MEMO1.Value+Edit1.Text; // this does not work

>Thanks Helmut

Re:append to memo(blob field)


Helmut try this -

if you want to append text to the last line of the memo

var
   i: Integer;
begin
    i := Table1.Memo1.Lines.Count -1;
    Table1.Memo1.Lines[i] := Table1.Memo1.Lines[i]+Edit1.Text;
end;

or if you want to append a new line to the memo field -

begin
    Table1.Memo1.Lines.Add(Edit1.Text);
end;

I hope this helps
Walter

Quote
Helmut wrote in message <769rv1$o...@forums.borland.com>...
>D4, BDE5.x
>How can I append text or rtf text to an memo field from program without
>using a memo field.

>eg Table1MEMO1.Value:= Table1MEMO1.Value+Edit1.Text; // this does not work

>Thanks Helmut

Re:append to memo(blob field)


I'm sorry Helmut I think I may have made a mistake.
If Memo1 is a field of a table then try this,
I have not actually run this but it should be close to a solution -

To append a string to the last line of the memo

var
    i: Integer;
    StringList: TStrings;
begin
    StringList := TStringList.Create;
    try
        StringList.AddStrings(Table1.FieldByName('Memo1').AsString);
        i := StringList.Count -1;
        StringList.Strings[i] := StringList.Strings[i]+Edit1.Text;
        Table1.Edit;
        Table1.FieldByName('Memo1').AsString := StringList.Text;
        Table1.Post;
    finally
        StringList.Free;
    end;
end;

to append a new last line to the memo

var
    StringList: TStrings;
begin
    StringList := TStringList.Create;
    try
        StringList.AddStrings(Table1.FieldByName('Memo1').AsString);
        StringList.Strings.Add(Edit1.Text);
        Table1.Edit;
        Table1.FieldByName('Memo1').AsString := StringList.Text;
        Table1.Post;
    finally
        StringList.Free;
    end;
end;

Walter

Quote
Walter wrote in message ...
>Helmut try this -

>if you want to append text to the last line of the memo

>var
>   i: Integer;
>begin
>    i := Table1.Memo1.Lines.Count -1;
>    Table1.Memo1.Lines[i] := Table1.Memo1.Lines[i]+Edit1.Text;
>end;

>or if you want to append a new line to the memo field -

>begin
>    Table1.Memo1.Lines.Add(Edit1.Text);
>end;

>I hope this helps
>Walter

>Helmut wrote in message <769rv1$o...@forums.borland.com>...
>>D4, BDE5.x
>>How can I append text or rtf text to an memo field from program without
>>using a memo field.

>>eg Table1MEMO1.Value:= Table1MEMO1.Value+Edit1.Text; // this does not work

>>Thanks Helmut

Other Threads