• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2917
  • Last Modified:

Visual Foxpro access retrieve data memo fields

Normally I never use in my applications memo fields. Always had some issues to use them, namely because it was not clear to me the way i should write and read data in these containers.
I would like to know the way I should write and retireve data from Visual Foxpro memo fields
and what kind of data I can insert into them.
Thanks in advance for you help
2 Solutions
CaptainCyrilFounder, Software Engineer, Data ScientistCommented:
I use memo fields to write lengthy values (more than 254 chars).
I also use memo fields to store Unicode text, RTF text and properties (ini files).
I used to store word documents, pictures, MS-Charts in memo fields only to display them in FRX Reports but now I store them outside the table and reference them from inside the table and the filenames are store in the memo fields.

To normally use memo fields
REPLACE table.memofield WITH cLongText
Thisform.editbox.Value = table.memofield

To store an object instance in a memo field use APPEND MEMO
APPEND MEMO notes FROM test.txt

To store General Fields: Pictures, Music Files, Charts, ...
CREATE TABLE MyGenTbl (mygenfield G)
APPEND BLANK  && Add a blank record

If you are using some DBF readers or database connections, you might have problems reading and writing from memo fields.

If you use COPY TO sheet.xls TYPE XLS it will not export memo contents. You will have to do that via Excel Automation.
Olaf DoschkeSoftware DeveloperCommented:
A normal memo is like a larger textfield, so you read and write to it like to a normal char field.
Cyril already discussed some other commands special to memos, but you don't need APPEND MEMO, it's just another possibility. You could also read in a file via FILETOSTR() and then store that as you store a value coming elsewehere into a char field. From that perspective it's as easy to use and maintain as any char field.

The difference is in how VFP displays memo contents. Simply use an editbox instead of any other control, and you get the memo content directly displayed instead of "memo" or "Memo", which is what foxpro displays in a textbox or a default grid column.

Another difference Cyril already told is the handling of memos in COPY TO and also EXPORT.

And yet another difference is, you can't GROUP BY memo fields in SQL, and you can't also SELECT DISTINCT with a memo field in the field list. I can only guess the machnisms doing these kind of sql operations need same size values and VFP would need to pad all memos to the same maximum length for that, which was considered as a bad thing performancee wise, so instead this was handled as forbidden, there may also be a size limit as the one for normal char fields.

There are some special memo field types, if talking about memo as a term for all field types stored in an fpt file, namely blob and general field. I'd avoid general in general, and blob is for storage of files, a special feature is you can set an image control pictureVal property to a blob field and let it display as picture, valid for images stored in blob, that foxpro can display, but it's easier and better to not put files into tables anyway.

Additional to that there is memo (binary), but that is also a form of field modification you have for other field types, eg char (binary). This simply means storage is not for a certain codepage and putting in values does neither check any codepage nor make any conversion, data is stored 1:1

Memo is convenient for larger portions of text, especially multi line. I mainly use it for comment/remark fields with less important data, that nevertheless will perhaps help to store some instructions of other short text passages.
I also sometimes use it for paths, as those can get longer than 254 chars. But I mainly use it for larger texts, not even for rtf, which is not wrong, but plain text without more formatting attributes is okay for my user base.

Bye, Olaf.
luciliacoelhoAuthor Commented:
Thank you Olaf and Ciryl for your information. i'm going to try your  helpful advises

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now