Results 1 to 8 of 8
  1. #1
    netchie is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    92

    Red face Specific Field Turn Red

    Hello,



    Is it possible for the report to change field (example Comment field) to different shade like red/yellow if one of the words on comment field has "extreme"? How can I do this?

    My rptGrade has a field called Comment and I want to change the shade to red or yellow on the report when it has a word "extreme". I can put whatever on my comment field but when one of the words has extreme, the field on will change to red or yellow.

    Thanks in advance,
    netchie

  2. #2
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Select the control which is bound to the Comment Field. Right-click on it and select CONDITIONAL FORMATTING.

    Once there, change the FIELD VALUE IS to EXPRESSION IS and then put this in:

    Instr(1, [Comment], "extreme") > 0

    and then select the colors you want for the background and text when that is true.

  3. #3
    pdebaets is offline Competent Performer
    Windows Vista Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Location
    Los Angeles
    Posts
    235
    In your report detail section OnFormat event procedure put the following code ("CommentControlName" is the name of the control on your report that holds the comment text):

    if instr(1,CommentControlName,"extreme") > 0 then
    CommentControlName.backcolor = 255 '* RED (you may want to adjust this color value)
    CommentControlName.backstyle = 1 '* Normal
    Else
    CommentControlName.backstyle = 0 '* Transparent
    End If

  4. #4
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Quote Originally Posted by pdebaets View Post
    In your report detail section OnFormat event procedure put the following code ("CommentControlName" is the name of the control on your report that holds the comment text):

    if instr(1,CommentControlName,"extreme") > 0 then
    CommentControlName.backcolor = 255 '* RED (you may want to adjust this color value)
    CommentControlName.backstyle = 1 '* Normal
    Else
    CommentControlName.backstyle = 0 '* Transparent
    End If
    Peter: I'd just use the Conditional formatting as it takes a lot less (and with Access 2010 you have up to 50 conditions). But definitely need to ensure that the control's backstyle is set to NORMAL, for sure, as that seems to be a problem occasionally and is not easily noticed by many.

  5. #5
    netchie is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    92
    Follow-up question: what if Im on View form section and checking what data I just entered to my fields, is it possible to see the word "extreme" in red not the whole fields? So only "extreme" will turn into red font? How to do this?

  6. #6
    netchie is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    92
    By the way, thanks for immediate replies. I'll follow your steps as soon as I get home.

    Have a great day!
    netchie

  7. #7
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Quote Originally Posted by netchie View Post
    Follow-up question: what if Im on View form section and checking what data I just entered to my fields, is it possible to see the word "extreme" in red not the whole fields? So only "extreme" will turn into red font? How to do this?
    I'd say as a practical thing, that is not possible. While technically is may be possible if using a Rich Text Box, it would be quite a pain to deal with, at least in my mind.

  8. #8
    pdebaets is offline Competent Performer
    Windows Vista Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Location
    Los Angeles
    Posts
    235
    It would be tricky, you'd have to have a Rich Text Box as Bob has said above. Then you'd have to check to see if the "extreme" text isn't already red... then you'd have to surround the "extreme" text with the html to make the text red. something like this (again from the OnFormat event procedure)(untested):

    if instr(1, CommentControlName, "<font color=""red"">") > 0 then
    else
    CommentControlName = replace(CommentControlName,"extreme","<font color=""red"">extreme</font>"
    endif

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

Similar Threads

  1. Delete Specific Text Strings in a Field
    By JET in forum Queries
    Replies: 5
    Last Post: 08-25-2011, 03:33 PM
  2. update field with specific content
    By luxeon in forum Queries
    Replies: 2
    Last Post: 01-24-2011, 03:29 PM
  3. Find specific value in any field
    By bkvisler in forum Queries
    Replies: 8
    Last Post: 12-08-2010, 04:23 PM
  4. Hyperlink to a specific Field/Cell?
    By tbutters in forum Database Design
    Replies: 8
    Last Post: 06-04-2010, 12:27 PM
  5. Replies: 1
    Last Post: 11-10-2009, 03:20 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