Changing the font (1 Viewer)

ECEK

Registered User.
Local time
Today, 14:50
Joined
Dec 19, 2012
Messages
717
My Sub form contains a notes section that is invariably used by the user by copy/pasting data from rich text environments into it.

What I am looking to do is to format the font name and size.
I have tried this however I'm not getting any success.
Code:
Private Sub notes_LostFocus()
Me.notes.FontSize = 7
Me.notes.FontName = "Arial"
End Sub

Would appreciate any experience with this thanks?
 

isladogs

MVP / VIP
Local time
Today, 14:50
Joined
Jan 14, 2017
Messages
18,186
For rich text, the font size & appearance is controlled in the rich text itself.
That is so where you want something other than the default size
See the attached for how examples on how to manage it
 

Attachments

  • RichTextExample.zip
    31 KB · Views: 213

ECEK

Registered User.
Local time
Today, 14:50
Joined
Dec 19, 2012
Messages
717
Thanks Isladogs

Great tool !! Many thanks

I now have my Rich text format namely:

<div><font face=Arial size=1>Text with border</font></div>

How do I apply this within my VB code?
 

isladogs

MVP / VIP
Local time
Today, 14:50
Joined
Jan 14, 2017
Messages
18,186
I would set the default for the form control using the property sheet.
No VBA needed
That will then apply unless you modify the font name/colour/size etc
You do so by editing the rich text direct

For example, I've just temporarily replaced the control default font with Curlz 7pt. Hideous isn't it!

However in part of record 3 I've changed it back to Calibri
 

Attachments

  • Hideous rich text example.PNG
    Hideous rich text example.PNG
    52 KB · Views: 162

ECEK

Registered User.
Local time
Today, 14:50
Joined
Dec 19, 2012
Messages
717
I think that we are at cross purposes here.

The user opens the form and pastes data into the notes field. This could have all manner of formatting but on closing the form (or losing focus on the notes field) I want to format what has been pasted to a specific font and specific size.

I tried putting the "<div><font face=Arial size=1>Text with border</font></div>" into the field format property but that hasn't worked
 

isladogs

MVP / VIP
Local time
Today, 14:50
Joined
Jan 14, 2017
Messages
18,186
I've just altered the control default to Arial 7 pt and pasted your last reply into the control. As you can see it works perfectly



I used no code whatsoever. It shouldn't be needed.
Suggest you disable your lost focus code

NOTE: The wider text box on the right just shows the rich text code in use. It doesn't have code tags for Arial 7pt (except for those you wrote in your 2nd para) as that's now the control default

HTH
 

Attachments

  • Capture.PNG
    Capture.PNG
    18.7 KB · Views: 666

ECEK

Registered User.
Local time
Today, 14:50
Joined
Dec 19, 2012
Messages
717
OK
I would like to open my form
paste my text into my notes field and for it to format to a specified format.
Can somebody help me with this please. I'm totally lost.
 

Gasman

Enthusiastic Amateur
Local time
Today, 14:50
Joined
Sep 21, 2011
Messages
14,044
I too copied isladogs bold and non bold text from his sig and pasted into a memo control of mine and it pasted fine.
Perhaps due to my table setting being set to Plain Text.?
 

isladogs

MVP / VIP
Local time
Today, 14:50
Joined
Jan 14, 2017
Messages
18,186
In my example, the memo field is set as rich text in the table.
That is why you won't see the code used in the table itself.
That code is used 'behind the scenes' to format the text.

I'm not really sure how to advise further.
Look at my example and do something similar.
Don't include the Plain text version in the form as you don't want to see the code.
 

ECEK

Registered User.
Local time
Today, 14:50
Joined
Dec 19, 2012
Messages
717
I can't explain it any simpler !!!

I open a Form

On that for is a field called notes (whose text format is set to Rich Text)

I paste into this field some copied Times New Roman pt 10 text

When I either lose focus or close the form: The format of the text changes to Arial pt7

When I reopen the Form the text is still at Ariel 7
 

isladogs

MVP / VIP
Local time
Today, 14:50
Joined
Jan 14, 2017
Messages
18,186
Sorry but me neither....
It should change to your default font as soon as you paste it into the form control.
No need to lose focus or close the form.

If still stuck, post a stripped down copy of your db
 

Minty

AWF VIP
Local time
Today, 14:50
Joined
Jul 26, 2013
Messages
10,354
I think that the OP is trying to change the rich text properties of the pasted text to arial 7pt.
Not just how it's displayed.

But I could be completely wrong.
 

ECEK

Registered User.
Local time
Today, 14:50
Joined
Dec 19, 2012
Messages
717
Hi Minty
Yes I guess that's what i'm trying to do.
Regardless of the format of my copied it should format to Arial 7 when triggered

Create a table with Notes (Rich Text)
Create a form
Add notes field
Open Form
Paste html times roman 10 into it
Close Form

Open form
Make the Times roman format to Arial 7
 

isladogs

MVP / VIP
Local time
Today, 14:50
Joined
Jan 14, 2017
Messages
18,186
No I think you are correct.
But my point is that it will happen automatically.
Just pasted Calbri 48pt text from Notepad into my form.
When pasted it becomes the default font (currently Arial 7pt) in both the form and of course the table where it is saved
 

ECEK

Registered User.
Local time
Today, 14:50
Joined
Dec 19, 2012
Messages
717
Could you post your new database please Isladogs
 

isladogs

MVP / VIP
Local time
Today, 14:50
Joined
Jan 14, 2017
Messages
18,186
Its the same database.
All I did each time was change the default font in the form control property sheet
 

ECEK

Registered User.
Local time
Today, 14:50
Joined
Dec 19, 2012
Messages
717
So now Im really confused
I open your database.
Paste my Times Roman text into a new Rich Text Field and it STAYS as Times new Roman and the Rich text code changes to:

<div><font face="Times New Roman" size=3 color=black>This is the the pasted Times Roman Text<strong> That is sometimes in BOLD</strong> but when I paste this from a word document I want it to change to Arial 7</font></div>


I want to paste a new record and for it to change to Arial 7.

I can't understand why nobody can understand what I'm trying to do !!
 

Attachments

  • RTExample.jpg
    RTExample.jpg
    99.7 KB · Views: 121

Gasman

Enthusiastic Amateur
Local time
Today, 14:50
Joined
Sep 21, 2011
Messages
14,044
We understand I believe. What I cannot understand is why it works for everyone else but you.?

I have just created a table with ID and RTF memo field.

I copied Mugger faces deportation after midnight attack on lone woman from https://www.walesonline.co.uk/news/wales-news/mugger-faces-deportation-after-midnight-15541069 and pasted that into the memo control and get the attached.

And that is just the default font created with the form. if I change it to Arial 12 in the properties and paste again, I get that font.?

Or am I missing something again.?
Also my RTF field does not show any formatting codes.?
 

Attachments

  • RTF.PNG
    RTF.PNG
    10.3 KB · Views: 125

isladogs

MVP / VIP
Local time
Today, 14:50
Joined
Jan 14, 2017
Messages
18,186
I do understand your frustration.
However, until your last post it sounded like you wanted to paste plain text from a text editor, paste it into Access and then format it in place

Now it is clear that you don't want that at all
Let me try to explain....

First of all you shouldn't be pasting rich text code (<div> etc) from Word into Access.
Just paste the text (formatted or otherwise)

If you post something like this:
This is the pasted Times Roman Text That is sometimes in BOLD but when I paste this from a word document I want it to change to Arial 7
into Access, you have already pre-formatted it so the rich text code will be 'retained' by Access when it is pasted


Notice the code has automatically been pasted across using this approach

So you have 2 basic choices without resorting to complex code
a) Format exactly as you want it to appear before pasting the text
b) Format it in Access after pasting

HTH
 

Attachments

  • Capture.PNG
    Capture.PNG
    17.5 KB · Views: 497

Gasman

Enthusiastic Amateur
Local time
Today, 14:50
Joined
Sep 21, 2011
Messages
14,044
Colin,

So why is it, when I paste highly formatted text into my RTF memo control, it takes on the set font properties of the control.?

TIA
 

Users who are viewing this thread

Top Bottom