[AccessD] A2000: Inserting HTML codes into a Text Box

Bob Gajewski rbgajewski at adelphia.net
Thu Apr 14 11:34:45 CDT 2005


Steve

You might want to consider using Stephen Lebans' Rich Text Format 2 control
(http://www.lebans.com/richtext.htm).

Regards,
Bob Gajewski
 

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Steve Erbach
Sent: Thursday, April 14, 2005 12:13 PM
To: Access Developers discussion and problem solving
Subject: [AccessD] A2000: Inserting HTML codes into a Text Box

Dear Group,

This is far from urgent. I'm simply trying to make it easier for a client.

I've set up a form for my client to add news items to a web page I put
together for her. There are text boxes for a date, a title for the item, and
for the text of the news item itself. That text box is called txtNewsItem.

There, of course, is no formatting in a text box; but I'd like to give my
client the option to insert the proper HTML codes for bold, italic,
underline, line break, etc. I could give her a cheat sheat with a few of the
codes listed and how to type them in properly, but I'd like to go a little
further. Is there a way for, say, the <b></b> codes to be inserted in a text
box with a keystroke like Ctrl-B?

I've been experimenting with SendKeys and OnKeyUp. I discovered that the
SendKeys action itself triggers the OnKeyUp event; so a bit of code like
this in the On Key Up event procedure does NOT work
properly:

Private Sub NewsItem_KeyUp(KeyCode As Integer, Shift As Integer) If Shift
And acCtrlMask Then
   Select Case KeyCode
      Case Asc("B"), Asc("b")
         SendKeys "<b></b>"
         ... etc.

So I moved the SendKeys to a Click event procedure of a button off to the
side of the txtNewsItem text box...but when I use code like this:

Private Sub cmdBold_Click()
   Screen.PreviousControl.SetFocus
   SendKeys "<b></b>"

... the HTML codes are placed at the END of the text in the box. The cursor
position is lost when the button is clicked.

Ideally I'd like the user to be able to select a block of text and press
Ctrl-B and have the HTML <b> and </b> codes appear surrounding the selected
text. Is this even possible?

Regards,

Steve Erbach
Scientific Marketing
Neenah, WI
www.swerbach.com
Security Page: www.swerbach.com/security
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com





More information about the AccessD mailing list