Results 1 to 7 of 7
  1. #1
    jhollingsh615 is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Apr 2011
    Posts
    30

    Conditional formatting stops working after changing field type

    I have a form that is based on a query from a single table. Two of the fields on the form were yes/no fields with conditional formatting(red background if field = "no"). This is a split database.
    After changing the yes/no fields in the backend to text fields, I can no longer get conditional formatting to work on the form, for those fields. Actually, conditional formatting works if I use only the "has focus" option of the default conditional formatting tab. But, it does not work for field = =



    I am at a loss what I could have done.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Why don't you get rid of conditional formatting and manage it with VBA? Maybe the "AfterUpdate" event...

    Something like

    If me.NameOfControl = "False" then
    me.NameOfControl.forecolor = 255
    else
    me.NameOfControl.forecolor = 0
    end if

  3. #3
    jhollingsh615 is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Apr 2011
    Posts
    30
    ItsMe, thanks for the quick response. Truth is, my coding knowledge is almost nil. I tend to create more problems than I solve when I try it. Was hoping to avoid more.
    And this was working great before I changed the underlying field. Even now, it works with the "has focus" option. Other fields can handle the "equal to" option, so I'm sure it has something to do with me changing the field type from yes/no to text. For the life of me I can't figure it out.
    But, I will try to run some tests with the VBA, if you say it is that simple.....

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    The complicated part is textbox control vs. checkbox control. It will be difficult to restrict what the user types into a textbox. You are trying to validate literal text and the slightest typo could remove any constraint you are trying to enforce. What is stopping the user from typing "Sure" or "Maybe" in the textbox? How are you going to validate input like that?

  5. #5
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by jhollingsh615 View Post

    ...After changing the yes/no fields in the backend to text fields, I can no longer get conditional formatting to work on the form...
    Just to be clear, you did change the expression in the Conditional Formatting, correct?

    [WhateverField] = Yes

    works for a Yes/No (Boolean) Field, but if the Field has been changed to Text the expression would have to be changed to

    [WhateverField] = "Yes"

    And ItsMe makes a very valid point; you'll have to validate that either "Yes" or "No" has been entered, or you'll have problems.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  6. #6
    jhollingsh615 is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Apr 2011
    Posts
    30
    Itsme and Missinglinq,
    Thank you both very much for responding so quickly. The field in question is only modified through a combo box with only "yes" or "no" as options.
    Missinglinq, as silly as I feel now, you identified the problem head on. Putting the quotes fixed everything.
    Thanks guys!!

  7. #7
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    As everyone here will tell you, 'databases' are all about the 'data,' and not all 'data' is the same! You have to know the Datatype in order to know how to handle it!

    Glad we could help!

    Good luck with your project!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Conditional Formatting based on another field - Part II
    By Harley Guy in forum Programming
    Replies: 8
    Last Post: 10-17-2013, 12:46 PM
  2. Replies: 5
    Last Post: 10-15-2013, 07:49 AM
  3. Replies: 7
    Last Post: 07-03-2012, 10:11 AM
  4. Replies: 1
    Last Post: 04-26-2012, 08:31 PM
  5. Replies: 18
    Last Post: 09-30-2011, 06:41 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