Code to Give the Italic Font only to selected tex

S

sebastico

Hello
I have a form to enter text data.In a txtbox field I need to change only the
selected font to italic.
Whenever the user needs to change the font,
I would like to have a bottom that once the tex is selected clicking the
button will change the font to italic.
Could d you tell me how to do it?

This is my Algoritm:

'Give the Italic Font only to selected tex
In myForm Open
Put the cursor in txtMyText text box
In the txtMyText select the desired text
With the text selected rigth click mouse to open the text box properties
Select the format tab
Change the Font Italic to yes

Due to I am beginir I would really appreciated if you add comment lines to
describe what the code means
 
A

Allen Browne

What version of Access are you using? A2007 is the only version that can
format part of the text differently to another part. If you are using a
previous version, you will have to use a 3rd party text box such as this
one:
http://www.lebans.com/richtext.htm

If you are using A2007, and you have a text box bound to a memo field that
has rich text set, you can use the button on the ribbon to italicize the
selected text. (This doesn't work for subforms.)

You cannot use a command button on your form for this task, due to timing.
When you click the button, Access first transfers the focus from the text
box to the button, and then runs the button's click event. Since the text
box has now lost focus, it has no selected text, so trying to italicize the
text that is no longer selected.
 
T

Tom van Stiphout

On Sat, 7 Nov 2009 21:44:11 +0800, "Allen Browne"

To work around the "no selected text" problem, you can save the
SelStart and SelLength to module-level variables in the
textbox_LostFocus event, and then use these values in the button_Click
event.

-Tom.
Microsoft Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top