Results 1 to 6 of 6
  1. #1
    mchadwick is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Posts
    71

    Compare Text and if begining is different then make the text red

    I have 2 fields in a record. the first 2 characters of the fields should be the same if they are not, I wouild like to make the text red so it stands out. Example:



    R1-core\bjones is in the LANDID field
    R1-core_-_Group is in the Group name field.
    This would be fine becuase "R1" is the same on both fields

    R1-core\bjones is in the LANDID field
    R2-core_-_Group is in the Group name field.
    This would be incorrect becuase they both have to begin with "R1" The LANID field will always be correct and the "Group Name" field would contain any mistakes.

    This is also a subform if it matters

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    ON CURRENT event of the form


    Code:
    if left(txtLandid,2) =  left(txtGroup,2) then
       txtBox.backcolor = vbWhite
    else
       txtBox.backcolor = vbRed
    end if

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Programmatically setting properties of controls in form set for Continuous or Datasheet view won't work. Use Conditional Formatting.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    mchadwick is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Posts
    71
    I did try the code and I didn't work for me. I know how to create conditional formating, but I am not sure what I need to write up in order for it to compare just the first 2 characters to ensure they are the same. Can you tell me how to do that?

  5. #5
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Very easy to set up conditional formatting:

    1) Open the form in design view.
    2) Click on the "Group" control.
    3) In the menu, click on the FORMAT tab
    4) Click on "Conditional Formatting"
    5) Click on "New Rule"
    6) In the first combo box, change to "Expression Is"
    7) In the text box enter Left([LANDID],2)<>Left([GROUP],2) << these are the control names
    8) Under the text box, click on the "A" and select the color you want.
    9) Click OK, then OK again.
    10)Change the form to normal view.

    Review the records.

  6. #6
    mchadwick is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2011
    Posts
    71
    Oh this is nice! Thank you very much for your help on this.

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

Similar Threads

  1. Replies: 2
    Last Post: 10-23-2014, 08:19 PM
  2. How to make all caps for a text box
    By data808 in forum Forms
    Replies: 16
    Last Post: 05-14-2014, 08:00 PM
  3. Replies: 3
    Last Post: 02-07-2013, 09:53 PM
  4. Replies: 14
    Last Post: 01-12-2012, 05:03 PM
  5. Make text click-able
    By Fifa in forum Access
    Replies: 5
    Last Post: 03-27-2011, 06:44 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