Go Premium for a chance to win a PS4. Enter to Win


Visual Foxpro access retrieve data memo fields

Posted on 2011-09-15
Medium Priority
Last Modified: 2012-05-12
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
Question by:luciliacoelho
LVL 27

Accepted Solution

CaptainCyril earned 1000 total points
ID: 36547224
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.
LVL 30

Assisted Solution

by:Olaf Doschke
Olaf Doschke earned 1000 total points
ID: 36548965
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.

Author Comment

ID: 36553334
Thank you Olaf and Ciryl for your information. i'm going to try your  helpful advises

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question