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!

Unbound Calculated Textbox: Partially bold? 2

Status
Not open for further replies.

lameid

Programmer
Jan 31, 2001
4,212
US
I feel as though this should be easy and I am missing something fundamental. I am using Access 2010.

I have a control whose control source looks something like:

Code:
="Some Text " & CalculatedText()

The control is centered on the form with the text centered, hence the desire to format a piece of it.

I did change the Text format property to Rich Text.

Either I am missing something fundamental about Rich text or the control has to bound to work...

I tried for example (and the forward slash too):

Code:
="Some Text \b " & CalculatedText()

Any insight would be greatly appreciated.
 
For some reason I do believe that is a correct statement that it has to be bound. You could make a small table with a single field and a single record and bind to the textbox.
 
I was afraid of that. And if I read correctly, the field has to be a memo field has text only supports plain text.
 
I have not verified, but I believe that is true.
 
Office Access 2007 stores rich text by using the Memo data type. This is the only data type in Access that has built-in support for rich text. To create a field for storing rich text, you create a memo field and then set that field's TextFormat property to RichText.

All discussion uses the word "field", so I think your assumptions are correct.
 
I think I am giving up as I cannot figure out how to take my text and progrmatically write it to the memo field with bolds in place.

On my form's load event I was playing with something like...

Code:
Me!VersionText = "<div>Some Text <strong>" & CalculatedText() & "</strong></div>"

I picked up the tags at runtime from formatting the text but it is just plain text when I concatenate it together and set the value.
 
Don't give up. You are simply not concatenating your string correctly
demo
Code:
Private Sub Command4_Click()
  Dim str As String
   Dim calcField As String
   calcField = "Hello World"
   Me.rtField = "This is some test and <div><strong>" & calcField & "</strong></div>"
End Sub

output
This is some test and Hello World
 
Don't run 2007/2010 as yet, so can't test this, but here is Allen Browne's commnet on the New Rich Text:

For the first time, you can format text a text box: bold, italics, bulleted lists, fonts, colors, etc. Use for comments, merge letter reports, ...

Applies to text boxes that are unbound, bound to an expression, or bound to a Memo field that has the Text Format property set to Rich Text (in table design.)

Note: stores HTML (not RTF.)


The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Missingling is correct. I tested it wrong the first time. There is no need to use a bound textbox (although the literature from MSDN makes you believe so). Using the above demo and making the textbox unbound, set the "text format" property to "Rich Text". It works.

So Lameid, I would think you should not have problem doing what you want.
 
Imagine that, documentation from Microsoft being misleading! Who'd a thunk it? [smile]

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
OK I am going to let MS off the hook this time. And chalk it up to a bad interpretation on my part.

Most controls, fields, and objects in Access have an associated series of properties. A property is a named value that defines some characteristic of the object — such as its position, size, and whether or not it is visible. The TextFormat property holds the setting that determines whether the text is treated as rich text or plain text.

You set the TextFormat property for the memo field in table Design view. The value you set there is inherited by any text box you create to display the data in the memo field. The value is inherited only when you create the control, however. You can subsequently change the value by using the property sheet for the text box.

I read the second paragraph as being a prerequisite for the first. Where in fact it is just saying that controls have a textformat property and memo fields also have a textformat property.
 
Sorry for not getting back sooner... Good point about the Rich Text being able to be set the same way.

As for Microsoft, I misread it the same way.

No reason it can't order things to say that the only way to store the data is in a memo field and to display it the property must be set which will default/inherit from the field in the table when ... Of course it needs to be wordsmithed but it gets my point across about ordering the ideas to be obvious (not like MS is paying us to do the tech writing).

As for ...

Code:
="This is some test and <div><strong>" & "Hello World" & "</strong></div>"


This displays
Code:
This is some test and 
[b]Hello World[/b]

Rather than
Code:
This is some test and [b]Hello World[/b]

Like I said I do not know the tags but a little testing to get the desired case...

Code:
="This is some test and <strong>" & "Hello World" & "</strong>"

I guess I finally found a reason to learn HTML.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top