Results 1 to 4 of 4
  1. #1
    Nanuaraq is offline Advanced Beginner
    Windows 7 32bit Access 2013 32bit
    Join Date
    Mar 2017
    Posts
    77

    How to generate rich text in a query response

    I have a query where a field is generated on basis of other fields. This query is used by caseworkers to do some calculations. The output is a text with useful directions for the caseworker.



    To lookup the case, I have a form where the case worker do a search by casenumber and get the corresponding case, with the calculations, presented on the screen.

    My caseworkers now ask me if the output text can be formatted. That will make it easier for them to identify their next step. Such as green for "go ahead with this one" and red for "stop, you need to see the boss about this".

    I am using simple IIf statements to do the calculations, and they return text formatted as simple text. Would it be possible for an IIf statement to return formatted text?

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    first, richtext will not work in a query, only a form or report where the control is set to rich text. However it should be possible to add the formatting codes as part of your iif statement. See this link which shows what the code looks like for different formatting (colour, bold etc) http://www.access-programmers.co.uk/...d.php?t=290820

    alternatively if the formatting applies to the whole field, you can use conditional formatting

  3. #3
    Nanuaraq is offline Advanced Beginner
    Windows 7 32bit Access 2013 32bit
    Join Date
    Mar 2017
    Posts
    77
    Quote Originally Posted by Ajax View Post
    first, richtext will not work in a query, only a form or report where the control is set to rich text. However it should be possible to add the formatting codes as part of your iif statement. See this link which shows what the code looks like for different formatting (colour, bold etc) www.access-programmers.co.uk/forums/showthread.php?t=290820

    alternatively if the formatting applies to the whole field, you can use conditional formatting
    I used the query to extract the needed formatting code, as explained in the link you provided.
    However, as you say it should be possible to add formatting codes to the IIf statement. But I can't seem to get it to work.
    For starters, I made an IIf statement like this:
    text: IIf(2=2;<strong>"truth"</strong>;0)
    But that's a syntax error.

    Then I tried:
    text: IIf(2=2;"<strong>truth</strong>";0)
    But that returns exactly this, in text format: "<strong>truth</strong>"

    So how may I add the formatting code to the IIf statement?

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    check the string again - did you include the div codes? and the control you have assigned the field to in your form/report is set to rich text?

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

Similar Threads

  1. Rich text field not displaying rich text properly
    By CodeLiftSleep in forum Access
    Replies: 4
    Last Post: 01-24-2018, 10:59 AM
  2. Replies: 3
    Last Post: 06-04-2017, 01:02 PM
  3. winhttp response text
    By hemaazez in forum Access
    Replies: 3
    Last Post: 05-23-2017, 06:01 AM
  4. Replies: 4
    Last Post: 08-07-2015, 07:49 AM
  5. Replies: 1
    Last Post: 05-24-2012, 04:59 AM

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