Results 1 to 5 of 5
  1. #1
    khughes46 is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Grapevine, TX
    Posts
    231

    How do I change the color of a filed in a form when the field entry changes for only that record?


    My user wants to be able to see a different text color when there are changes to certain fields and only those fields for only the record that is changing. I tried to change the fields in aferupdate but that changed all the records.

  2. #2
    trevor40's Avatar
    trevor40 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Feb 2014
    Location
    Australia
    Posts
    407
    Quote Originally Posted by khughes46 View Post
    My user wants to be able to see a different text color when there are changes to certain fields and only those fields for only the record that is changing. I tried to change the fields in aferupdate but that changed all the records.
    you can set the color using VBA

    me.text_box_1.forecolor = VbRed or 255

    (you will also see a reference to the forecolor in the text field properties dialog, this shows the default color)

    you can set this at many form/field states, you need to pick the best one for your situation. ie gotfocus, beforeupdate, afterupdate, lostfocus, ...

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    My user wants to be able to see a different text color when there are changes to certain fields and only those fields for only the record that is changing. I tried to change the fields in aferupdate but that changed all the records.
    So the form is in continuous forms view. The easy answer is that you can't. The hard answer is that it could take a LOT of code.

    Try this:
    Here is the set up:
    You have Table1 with Field1 (Text).
    You create query1 based on Table1.
    Query1 is the record source for Form1.
    Control1 (a text box) is bound to Field1.
    The detail section of the form is just tall enough to hold Control1
    Form1 default view is set to continuous forms view.

    Let's say that Table1 has 5 records.
    Switch Form1 from design view to Normal view.
    The question is: "How many controls are on Form1?

    The answer is ............. 1. Switch to design view again. Count the controls.
    This is why when you chage the back color of one control, all of the controls back color change.



    Part 1
    ---------
    Open Table1 in design view. Add another field - Chkbox1 (Yes/No) Save the table.
    Add Chkbox1 to Query1. Save Query1
    Open Form1 in design view. Add Chkbox1 to the detail section.
    Add conditional formatting to Control1 -> Create New Rule.
    First combo box, change : "Field Value Is" to "Expression is"
    Second box, enter: [Chkbox1]=TRUE
    Click on the red "A". Select RED. (Click "B" if you want to bold the value.Save the format. (OK)(OK)
    Switch the form to normal view.

    Check one of the check boxes. Control1 text should change to red and only that one record should change.
    Unchecking the checkbox should return the forecolor to black.

    Part 2
    ----------
    Set the visible property of the check box to NO.

    Now the hard part.
    Somehow you have to be able to determine WHEN the text has change for a specific control.
    So when the text changes, Chkbox1 is set to True and conditional formatting will change only that one control fore-color.

    Then after the record is saved, the fore-color should be reset to automatic or black.




    ---------
    If you have 5 text box control that you want the fore-color to change, that means adding 5 check box fields to a table, setting up 5 controls for conditional formatting and code to check when the text changes for each of the 5 controls.


    Soooooo, lots of code......

  4. #4
    khughes46 is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Grapevine, TX
    Posts
    231
    I see how much that involves and I have 7 fields to change. What if I just wanted to highlight the record that has changed to set the background to a different color?

  5. #5
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    What if I just wanted to highlight the record that has changed to set the background to a different color?
    That I have done.

    Still involves a Boolean (Yes/No) field in a table and code. Add the check box field to the query and add to the form. Set up conditional formatting.
    The trick is still determining when data has changed for any control in that record.
    Data changes, code sets the (hidden) check box control to true. Box control changes background color.


    My check box was to select records to print. Seeing which check box was checked was difficult, so I added a Box control that spanned the width of the form. Then set up conditional formatting.
    The box control was sent to the background; when the check box was selected (checked), the box control changed color behind all of the other controls.
    Then was easy to see which records were selected.... like 30 records selected out of 150 total records (making an isolation list).

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

Similar Threads

  1. Replies: 7
    Last Post: 06-26-2014, 01:41 PM
  2. Change field color based on result
    By dniezby in forum Programming
    Replies: 1
    Last Post: 05-01-2013, 09:43 PM
  3. Replies: 5
    Last Post: 09-18-2012, 12:39 PM
  4. Replies: 8
    Last Post: 04-26-2012, 10:13 AM
  5. Color change in form filed
    By miziri in forum Programming
    Replies: 3
    Last Post: 08-15-2009, 04:53 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