Results 1 to 8 of 8
  1. #1
    Henners is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Aug 2018
    Posts
    6

    Using html code to format items in a combobox

    Hi all,
    I am trying to get a combo box to display a list of items but if the items fit a certain criteria then part of the items text will be another color.
    I.e. If the item in the list says "week 1 ---> homework " then I want to change the word homework to red.
    I had a little play around with a textbox and used the following:


    Me.Text3.TextFormat = acTextFormatHTMLRichText
    Me.Text3.Value = "<p><strong>He<span style=""color: #ff0000;"">ll</span>o</strong></p>"

    All fantastic the ll in Hello is red. But there is no textformat property for a combobox.
    Does anyone know of a way to do this without using a textbox ?

    Side note: The html is coming directly from the field and is not being modified at runtime. I do the manipulation in a stored procedure and then put the end results into a field. Setup is MSSql db with an Access front end.

    Thank you kindly H

  2. #2
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    AFAIK it is not possible to format list item. Anything you'll find re conditional formatting or whatever, applies to the displayed value, which I think is not what you're asking for. I have read that there is/was an ActiveX control called ImageCombo with which you could display small icons to add a bulleted effect but I'd caution against using any non standard Access control. Other than that, you'd have to fake it with a small continuous form or something similar. A lot of work for little payback IMHO.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    You can do limited formatting for both combos and listboxes. See http://www.mendipdatasystems.co.uk/a...our/4594424152
    However, whether this offers enough to meet your needs is another matter.
    Alternatively, you could use a subform to mimic a combo and make use of the additional formatting available in the underlying query.
    Last edited by isladogs; 04-25-2019 at 10:16 AM.
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  4. #4
    Henners is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Aug 2018
    Posts
    6
    Owww that's a bit of a bummer. Well I think I will just add a textbox and populate it with the html code. Hide the lstbox and then when the user clicks on the textbox show the listbox and setfocus to it.
    Not sure how it will work out but I will aim for something like that.
    Thanks for taking the time to answer me Micron and isladogs much appreciated.

  5. #5
    Henners is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Aug 2018
    Posts
    6
    Quote Originally Posted by Henners View Post
    Owww that's a bit of a bummer. Well I think I will just add a textbox and populate it with the html code. Hide the lstbox and then when the user clicks on the textbox show the listbox and setfocus to it.
    Not sure how it will work out but I will aim for something like that.
    Thanks for taking the time to answer me Micron and isladogs much appreciated.

    That cunning plan did not work. The end result was an formatted text box. Just does not seem to want to play ball when it is a datagrid.

  6. #6
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    As previously suggested, why not use a subform that has similar functionality but more potential for formatting the way you want
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  7. #7
    Henners is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Aug 2018
    Posts
    6
    Quote Originally Posted by isladogs View Post
    As previously suggested, why not use a subform that has similar functionality but more potential for formatting the way you want
    Isladogs I am lost on that one. Have you got an example you could share with me?

  8. #8
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    Which part don't you understand?
    You can use a continuous or datasheet subform with one or more fields (columns) so it looks similar to a listbox
    You can use conditional formatting to make the appearance exactly as you want - HTML wouldn't be used (or needed)

    However if you want HTML formatting, you can use a memo field set as 'rich text'

    I've attached an example of each in case they are any use
    Attached Files Attached Files
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 7
    Last Post: 10-20-2015, 04:51 PM
  2. email body using html format
    By baronqueefington in forum Programming
    Replies: 5
    Last Post: 02-03-2015, 03:44 PM
  3. Chr(13) & Chr(10) in HTML format
    By cbrsix in forum Programming
    Replies: 3
    Last Post: 09-25-2013, 02:37 PM
  4. Replies: 1
    Last Post: 01-24-2012, 08:31 PM
  5. Replies: 0
    Last Post: 03-24-2011, 11:09 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums