Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bold a portion of a Label's `Caption` property in VBA (Microsoft Access)

Tags:

label

vba

How do I bold a certain word in the caption of a Microsoft Access label?

If it helps, the text itself is stored in a Microsoft Access table.

An example is below. I have a Microsoft Access form with a label, in the Form_Load() event I set the caption property of this label to the value returned in a DLookup query like so:

Private Sub Form_Load()

    Me.Label0.Caption = DLookup("Field1", "Table1", "[ID] = 1")

End Sub

My text is as follows:

The quick brown fox jumps over the lazy dog

I want to embolden the word Lazy. Is this possible? If so, how do I do this?

Thanks

like image 741
JMK Avatar asked Aug 10 '12 14:08

JMK


People also ask

Can you bold text in VBA?

To make any text bold in VBA, we can use the Font. Bold property of a Range or Cell.

How do you make text bold in access?

Let's apply boldface formatting to the selected text labels. Click the Bold button on the Formatting toolbar. The selected controls appear in bold. Click the Save button to save your changes to the report.


1 Answers

You do not mention the version of Access, for 2007 (AFAIK) and 2010, you can create a textbox and set the Text Format on the data tab to Rich Text. You can then set the Control Source to:

="The quick <b>brown</b> fox"

Change a few more properties, such as Locked and Enabled and you will have a textbox that looks and acts like a label.

like image 60
Fionnuala Avatar answered Sep 30 '22 16:09

Fionnuala