View member feedback to this tip.
One big issue with rich text fields is that "Modifications made to rich text items on the back-end document do not appear on the current document until it is closed and reopened." This means that any code you might have in the UI accessing a rich text field (create tables, append doc links, etc.) won't immediately show up without saving and re-opening.
Until now, either you saved and re-opened the back-end doc to reflect the changes to the rich text field (which meant that you also had to incorporate some sort of clean-up code if a user chose to cancel the save) or you don't reflect the changes in the UI, which can cause some user confusion ("yes, you did make the changes but you have to save and re-open the doc to see them").
With the following code, you can modify any rich text fields and reflect those changes in the UI without being forced to save the document. In this example, I am appending a document link but I have tested the code for creating a table as well. The user may notice a slight flicker as the document is closed and re-opened.
One other application for this code is Computed Subforms. In the Designer Help, it is stated that "Subform formulas cannot be refreshed while the document is open." This method of re-initializing the document in memory allows the Computed Subform to change.
MEMBER FEEDBACK TO THIS TIP
This works well, but the document you are working with must have been saved first. If it has not been saved, when the line of code shown below runs, you will get an error because the field is not actually a rich text field element yet. It will only be that after the document has been sa...
To continue reading for free, register below or login
To read more you must become a member of SearchDomino.com
');
// -->

ved at least once.
If ( nitem.Type = RICHTEXT ) then you will receive this error if the document has not been saved:
[IMAGE]
Steve H.
******************************************
I have tried to use to code to embed an attachment in the
rich text field body, but I can not get rid of the field save options.
Anonymous
******************************************
You can try modifying the code as follows:
Also, if the form you are working with is not the default form in the database, you should also add a Computed Form field to the form so that when the code closes and re-opens the document, it knows what form to use.
Bryce Berry, tip author
******************************************
I thought this tip would be the thing, but I then found an easier way. I hope this is useful. Also, I'm using VBA / Excel.
I send the doc to an empty/blank address, and trap and ignore the error. When I create the uidoc, my body appears, and I didn't have to save the doc first.
Michael R.
Do you have comments on this tip? Let us know.
This tip was submitted to the SearchDomino.com tip exchange by member Bryce Berry. Please let others know how useful it is via the rating scale above. Do you have a useful Notes/Domino tip or code to share? Submit it to our monthly tip contest and you could win a prize and a spot in our Hall of Fame.