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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Rich Text Formatting with code

Status
Not open for further replies.

ghacig

Technical User
Sep 24, 2004
60
US
Hi

I am using MS Access 2007. I have a memo field with property set to rich text format. I use code to compile data from several tables to populate the memo field. I wonder if there is a way to apply rich text formatting on specific parts of the memo field using code. For example: make a title Bold, or creating numbering using the code as opposed to doing it later with the mini tool bar.

Thanks.
 
Yes, just apply the rich text tags.
 
Thank you. How do you do that. Is there a help file? Thanks.
 
See thread702-1671061 for a simple example. You will have to provide some more specifics of what you are trying to get a more focused answer.
 
Thanks again. I am trying to format a long report with things like Bold title and bullets and numbering. So I probably just need simple tags. I have no experience with HTML tags. Any help is greatly appreciated in terms of text selection and tags. The code that populates the memo field is long and pulls data from several tables into a single long note (FinalNote). It is something like this:

FinalNote = "HISTORY:" & vbNewLine & vbNewLine & stHistory etc...

I need to make "HISTORY:" bold, or possibly underlined. Thanks for your help.

 
I do not have experience with the tags so I do this trick. Put some text in a rich textbox and apply some different formatting. Then you can print the value to the immediate window or another non rich textbox.

debug.print me.SomeRichTextBox.value

Now you will see the tags and you can figure out how to format.

I would then build myself some reuseable functions to apply the tags. Pass in a string and return the string wrapped with the appropriate tags.

Code:
public function boldText(strText as string) as string
  boldText = "<div><strong>" & strText & "</strong></div>"
end function

public function underlineText(strText as string) as string
  underlineText = "<div><someTag>" & strText & "</someTag></div>"
end function

.....


Code:
 ....
 FinalNote = boldText("HISTORY:") & vbNewLine & vbNewLine & stHistory etc.
 
Great advice. Thanks so much for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top