Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Memo

Status
Not open for further replies.

rkdua66

Programmer
Jul 25, 2013
8
IN
Hi,

I am developing a software for correspondence received from investors. In this system i have to generate letters and i am using memo field for standard letter format. But in some cases i need to put field values from other table in text of memo field at runtime.

Anyone having any idea in this regard. Pls help me.

Thanks
Ravinder Dua
 
Develop some kind of 'tag' arrangement and do a STRTRAN() to replace it at run-time...

For example, you might put [FULLNAME] in the letter and do a STRTRAN(m.MyMemoField,"[FULLNAME]",Alltrim(MyTable.Fullename)) to get the right value in there.

Code:
Function ProcessLetter
  Parameter M.MemoField
  Local M.String
  m.string = STRTRAN(m.MemoField,"[FULLNAME]",Alltrim(MyTable.FullName))
  m.string = STRTRAN(m.String,"[ADDRESS]",Alltrim(MyTable.Address))
  m.string = STRTRAN(m.String,"[TEL NO]",Alltrim(MyTable.TELNO))
return(m.string)

You could write a function like the one above


Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
Thanks Griff,

I will try this and inform you.

Ravinder Dua
 
Hi Ravinder, and welcome to the forum.

What you need to do is to put place-holders in the memo field, at the points where you want to insert the variable text.

For example, suppose you want the letter to say:

Dear Mr Rockefeller,

Thank you for letter of 2 August 2013.

where "Mr. Rockefeller" and "2 August 2013" are variable text that you obtain from another table.

You would replace these variables with place-holders, for example:

Dear #1#,

Thank you for letter of #2#.

I've used #n# for the place-holders in this example, but you could choose whatever combination of characters you prefer.

When the time comes to generate the letter, you can do so like this:

Code:
* Assume TableA contains the memo field, named MemoField;
* Table B contains the investor's name (InvestName) and date of last letter (LetterDate)
lcGeneratedText = STRTRAN(TableA.MemoField, "#1#", TableB.InvestName)
lcGeneratedText = STRTRAN(lcGeneratedText, "#2#", TableB.LetterDate)

* lcGeneratedText now contains the new text, which you can to ahead and print.

Obviously, this is greatly simplified, but it should give you the general idea.

Be aware that this method is not particularly flexible. Also, it does not allow you to vary the formatting or style of the generated text. You cannot format individual words or phrases in different fonts, or use bold and underline, for example. If that's an issue, you should consider using mailmerge with Office Automation. If that's of interest, we can give you more guidance, but it's more complicated than the method I've outlined above.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
the hashtag idea is rather more elegant than my []

B-)

And your explanation fuller


Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.
 
Well, there is the TEXTMERGE() function for that, and it can replace in all such placeholders at once and you can use any expressions you want between the markers << and >>.

I would prefer that over the reinvented wheel, as long as not the users are writing and maintaining such text templates.

You simply have to take care all needed tables are opened and positioned on the correct record, if eg using fields as the source of eg <<fieldname>>, but you can also place <<DATE()+7>> or any expression you want evaluated from TEXTMERGE().

Bye, Olaf.
 
Glad you mentioned it, Olaf. I was about to ask why they were reinventing textmerge when I got to your post. [wink]
 
Just to reinforce all of the above. I have done almost exactly what as been proposed. I also built a table of the possible replacements.This made it easy for me to add new place holders.
Code:
Place Holder Source
FirstName    Alltrim(Table1.FirstName)
LastName     Alltrim(Table1.LastName)
FullName     Alltrim(Table1.FirstName) + Alltrim(Table1.LastName)
HeShe        IIF(Table1.Gender = "F", "She", "He")
HimHer       IIF(Table1.Gender = "F", "Her", "Him")
Company      Alltrim(Table2.Company)
...
I had the user maintain their own templates and had them put "~" on each side of the place holder. I also had them capitalize the place holder when they wanted all uppercase like ~FULLNAME~. It is obviously important to make sure the tables are on the correct records. After I did this the first time I pre-selected the replacements into a cursor to eliminate the possibility of having any table being on the wrong record. Then I removed Table1, Table2 from the place holder source column.

Auguy
Sylvania/Toledo Ohio
 
i am using memo field for standard letter format

One of my clients needs a variety of 'standardized' letters sent out daily.
We do NOT use Memo fields for this.

VFP Report Forms were created for each of the 'standardized' letters and those 'reports' are then run as needed with the appropriate data.

Then the Reports are run to a PDF 'printer' which creates the appropriate letter as a file - which can then be sent to the recipient as an email attachment or in some other manner.

Good Luck,
JRB-Bldr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top