[AccessD] Rich text text boxes

Jim Dettman jimdettman at verizon.net
Tue Jul 12 10:07:54 CDT 2022


<<.  I am already running into 'use css' for stuff I want to do, and (not sure but) I don't
think the control understands css.>>

 It does not.   It's not a web browser.   What it does handle is minimal:

https://support.microsoft.com/en-us/office/create-or-delete-a-rich-text-field-9f86237d-dbbc-4a85-b12c-9d8dca824630?ocmsassetid=ha010014097&correlationid=c03a1d03-0e4a-496b-9033-489f64aa9462&ui=en-us&rs=en-us&ad=us

 This article does not have the actual tags, but are the types of things you can mess with.   Basically the simple formatting (Font, Bold, Italic, Color, etc).  You won't find support for things like tables.

 Not sure what you are trying to achieve, but the new Web View 2 Control should be released soon.

Jim.



-----Original Message-----
From: AccessD On Behalf Of John Colby
Sent: Tuesday, July 12, 2022 10:59 AM
To: Access Developers discussion and problem solving <accessd at databaseadvisors.com>
Subject: Re: [AccessD] Rich text text boxes

Ryan,

I just got this working an hour ago, and what I have working is bog
standard simple so far.

The text control is obviously NOT a browser.  How it works is a mystery,
however it does allow at least a modicum of HTML formatting.  I am already
running into 'use css' for stuff I want to do, and (not sure but) I don't
think the control understands css.

I am considering whether to add a clsHTMLLine to handle all of the HTML
'stuff' for a given line of text.    Thus a line could be treated as its
own entity and stored in a collection in my txt control class, rather
simply appending it to one big html string and moving on.  One big HTML
string is obviously simpler and what I am doing for now.



On Tue, Jul 12, 2022 at 10:47 AM Ryan W <wrwehler at gmail.com> wrote:

> I've recently been mucking with Rich Text too, though I am just allowing
> users to use the text formatting options in the ribbon in the rich text
> field.
>
> I did find that the only thing setting the Text Format property on a
> table/column does is make Access smarter when you drag and drop that
> field/column onto a form (or when you use a form/report creation wizard),
> it auto sets the control bound to the column to Rich Text .
>
> Binding the form/report control to a non rich text column (say in a linked
> table) only requires you to set the control to allow Rich Text to get those
> "benefits" thankfully. I didn't want to mess with my ODBC Linking code to
> also handle column properties.
>
> And just like you, I did find that programmatically trying to add wording
> to rich text fields stinks. I simply chose when I needed to add to that
> column via VBA was to simply wrap whatever I was adding in div tags.   I'll
> let my end users chose what to do with the phrasing added on their own
> accord.
>
> On Tue, Jul 12, 2022 at 9:31 AM John Colby <jwcolby at gmail.com> wrote:
>
> > I'm sure some of our more experienced members will slap me around, but I
> > just had to share my solution.
> >
> > Problem: the rich text text box in access "only works" bound to a rich
> text
> > field.  Furthermore, the data in the field is HTML (ish) and all of that
> > formatting stuff apparently is not available to get back from said field.
> > Which makes writing rich text programmatically a roya PITA.  I have spent
> > the morning googling and found pretty much nothing, at least in the
> Access
> > vba side of the house.
> >
> > Solution:  Wrote my own.
> >
> > The answer lies in generating HTML dynamically.
> >
> > However before you can do ANYTHING you have to get a text box with it's
> > format set to 'Rich Text' which is non-trivial.  In fact the only way I
> > have found to do so is to create a table with rich text fields, then
> bind a
> > form to that, then bind a text box to one of those fields, then set the
> > format of the text box to 'Rich text' which is suddenly available simply
> > because it is bound to a rich text field.  Once I had that , I unbound
> (is
> > that a word) the text box, but it kept the 'Rich Text' format.  Voila a
> > text box that can understand and process HTML tags.
> >
> > From there, I created a class (of course).  The objective of the class is
> > to wrap a 'Rich text' text box and allow vba to do the mucking around
> with
> > html format codes.
> >
> > I pass in the text box to the init and store the text box in the header
> of
> > the class so I can access it inside of the class.
> >
> > I then wrote a function to pass in a message I wanted to display in the
> > text box and a boolean to bold it or not, defaulted to not.
> >
> > Function fWriteTextBox(lstrMsg As String, _
> >                             Optional blnBold As Boolean = False)
> >
> > Dim lstr As String
> >     lstr = lstrMsg
> >     If blnBold Then
> >         lstr = "<b>" & lstr & "</b>"
> >     Else
> >     End If
> >     If mLineCnt > 0 Then
> >         lstr = "<br>" & lstr
> >     End If
> >     mstrHTMLMsg = mstrHTMLMsg & lstr
> >     mtxtStatus.SetFocus
> >   mtxtStatus.Text = mstrHTMLMsg
> >     mLineCnt = mLineCnt + 1
> >
> > Exit_fWriteTextBox:
> >     On Error GoTo 0
> >     Exit Function
> > end function
> >
> > In the form header
> >
> > Dim mclsLicenseStatusText As clsStatusText
> >
> > In the Form_Open
> >
> >     Set mclsLicenseStatusText = New clsStatusText  'Instantiate the beast
> >     mclsLicenseStatusText.Init Me, txtLicenseStatus  'Pass in the text
> box
> >
> >     mclsLicenseStatusText.fWriteTextBox "This is a test" 'Write a string
> > without bold
> >     mclsLicenseStatusText.fWriteTextBox "This is a BOLD test", True '
> Again
> > with bold
> >
> > GUESS WHAT!  IT WORKS!!!
> >
> > The text box in my form displays the two lines of text stuff, one bolded,
> > the other not.
> >
> > Can you say ROYAL PITA?  But IT WORKS.
> >
> > So now I need to flesh out the class to allow other format tags.  I
> desire
> > to allow colors, bold, italics, font etc.  Slowly over time I think I can
> > do this thing.  We shall see if and what the limitations of the text box
> > are.  But I am simply jazzed that I can do anything at all of this
> nature.
> >
> > Furthermore the built up HTML string is available for me to look at /
> read
> > back as opposed to the 'bound to a table' method.
> >
> > OK, now the real heavyweights of the list can commence the
> slapping.🤕😜😁
> > --
> > John W. Colby
> > Colby Consulting
> > --
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > https://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
> >
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> https://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>


-- 
John W. Colby
Colby Consulting
-- 
AccessD mailing list
AccessD at databaseadvisors.com
https://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list