Rich Text Font (AfterUpdate) (1 Viewer)

ajm_1984

New member
Local time
Today, 08:40
Joined
May 30, 2018
Messages
2
Hi All

I am hoping someone can help me out. I have a continuous form that has a number of fields however one of these fields [Details] is set to Rich Text.

What i am trying to do is have some code on AfterUpdate to ensure that any text entered is changed to a specific font family and size - Calibri Size 10.

The code i have tried does not seem to work - i do not get any errors but it doesnt change the font. The code i am trying is as below:

Private Sub Details_AfterUpdate()
With Me.[Details]
.SetFocus
.FontName = "Calibri"
.FontSize = 10
.ForeColor = vbBlack
End With
End Sub

Can anyone point me in the right direct? Thanks in advance
 

isladogs

MVP / VIP
Local time
Today, 08:40
Joined
Jan 14, 2017
Messages
18,255
It should change the font size but it can't update font colour or other formatting because its using rich text formatting (effectively a subset of HTML)

For example, rich text 'Hello world' is actually saved as: <div><font color=red><strong>Hello </strong></font>world </div>

Change the textbox on the from to plain text to see what your text actually is

The obvious point to make is that if you want all text to be Calibri 10pt black then just use plain text instead of rich text

P.S. Welcome to the forum
 
Last edited:

ajm_1984

New member
Local time
Today, 08:40
Joined
May 30, 2018
Messages
2
It should change the font size but it can't update font colour or other formatting because its using rich text formatting (effectively a subset of HTML)

For example, rich text 'Hello world' is actually saved as: <div><font color=red><strong>Hello </strong></font>world </div>

Change the textbox on the from to plain text to see what your text actually is

The obvious point to make is that if you want all text to be Calibri 10pt black then just use plain text instead of rich text

P.S. Welcome to the forum

Thanks for the response ridders and thanks for the welcome!

I would love to be able to use plain text - the reason i have had to use rich text is because my tables are exported and linked to a sharepoint site - and this sharepoint site doesnt seem to like carrige returns in plain text!

I was hopeful that there would be some code that could change the font type for a rich text field but doesnt look so! what a shame!

Thank you anyway.
 

isladogs

MVP / VIP
Local time
Today, 08:40
Joined
Jan 14, 2017
Messages
18,255
I've no experience of SharePoint lists but that seems very odd if its true

Anyway, there's a hard way & an easy way:

The hard way is to use the replace function
Write a procedure or a series of update queries that goes through your table replacing each instance of unwanted rich text formatting

e.g.
Code:
Me.Details=Replace(Me.Details,"<font color=red>","")
Me.Details=Replace(Me.Details,"</font>","")
Me.Details=Replace(Me.Details,"<strong>","")
Me.Details=Replace(Me.Details,"</strong>","")

But you will need to replace every type of formatting text used

The easy way is to use the PlainText operator:


Code:
SELECT Table5.ID, Table5.Details, PlainText([Details]) AS PlainTextDetails
FROM Table5;

I know which I'd go for ...
 

Attachments

  • Capture.PNG
    Capture.PNG
    9.4 KB · Views: 524

Users who are viewing this thread

Top Bottom