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

Formatting a rich text box 1

Status
Not open for further replies.

georgesOne

Technical User
Jul 2, 2004
176
JP
Dear All:

I use the following code snippet (replace function) to modify the attributes of a text item in a rich text box (Topic1 is a textbox, sFieldName is a variable)

Code:
  .....  
  Const sTagColor = "<font color=""""red"""">"
  Const sTagLarge = "<font size=""""3px"""">"
  Const sTagEnd = "</font>"

  If sFieldName = "Topic" Then
    Me.Topic1.ControlSource = "= IIf([" & sFieldName & "] Is Null, Null, " & _
      "Replace([" & sFieldName & "], """ & sDescriptor & """, """ & _
      sTagColor & sTagLarge & sDescriptor & sTagEnd & sTagEnd & """))"
  End If
  .....

This works, but I cannot get the constants/nomenclature for making the selected text => bold and the background of the selected text => yellow.
Any help? Thanks, georges.
 
Build a form with two text boxes. Make the first rich text and the second plain. Then have a button to make the value of the secon equal to the first. So you can format in the first and read the tags in the second. Now you have an easy way to get any tag.
 
also for simplicity I believe you can just do
<font color='red'>
or I think even
<font color=red>
 
...and then: can I replace two or more items?
This was my afternoon topic... But so far no success.

Best, georges
 
can I replace two or more items?
Not sure what you are asking here.

Your code is really hard to read, and impossible to debug. Maybe simply
Code:
  Const sTagColor = "<font color='red'>"
  Const sTagLarge = "<font size='3px'>"
  Const sTagEnd = "</font>"
  dim strText as string
  sFieldName = "[" & sFieldName & "]"
  
  if not trim(sfieldName.value & " ") = "" then
    strText = sFieldName.value
    stText = sTagColor &sTagLarge & strText & sTagEnd & sTagEnd
    debug.print strText
    'now you can error check
    me.Topic1.value = strText
  End If
Do you have to mess with the control source? Are you also editing in this field?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top