Board index » delphi » Assigning Text to a Memo Field

Assigning Text to a Memo Field

What is the easiest way to assign a simple text string to a memo field?

I'm trying to use the syntax:
    MyTable.FieldByName('My Memo').AsString := 'Junk';
But, of course, I get the error "cannot access the field 'My Memo' as
'String',

So, how do I assign a simple string to a MemoField?

Thanks,
Jesse

 

Re:Assigning Text to a Memo Field


Jesse:

You have to use a typecast to tell the compiler that you are dealing with a
TMemoField. e.g.:

  Table1.Edit;
  TMemoField(Table1.FieldByName('Comments')).AsString := 'Meaningful stuff';
  Table1.Post;

"Comments" is a memo field in my test database.
--
Regards
Ralph (TeamB)
Herrsching, Germany

Quote
Jesse Castleberry wrote in message <6inqmi$1...@forums.borland.com>...

|
|So, how do I assign a simple string to a MemoField?

Other Threads