Results 1 to 5 of 5
  1. #1
    BenHPieters is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Location
    Johannesburg
    Posts
    10

    Adding background colour to a form field based on option box selection for that field

    I require to add a background colour, eg Green for "solved" and red for "open", to a form field based on the selection from an option box for that field.


    Any advice please?
    BenHPieters

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Use conditional formatting
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    BenHPieters is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Location
    Johannesburg
    Posts
    10

    Conditional formatting does not cover text in a form field

    Quote Originally Posted by isladogs View Post
    Use conditional formatting
    The conditional formatting functionality does not cover text in a form field selected from an option box, only values and expressions.
    How do I overcome this?

  4. #4
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Yes it does. For example:

    Click image for larger version. 

Name:	Capture.PNG 
Views:	20 
Size:	17.2 KB 
ID:	37301

    Alternatively, use the AfterUpdate event for the Option Group:

    Code:
    Private Sub Frame11_AfterUpdate()
    
    Select Case Me.Frame11
    
    Case 1
        Me.Field1.BackColor = vbGreen
    Case 2
        Me.Field1.BackColor = vbRed
    End Select
    End Sub
    Either will work fine for a single record but will affect ALL records if it is a continuous form.
    If your want to mark records individual records on a continuous form as solved/open, add a boolean field with a checkbox
    Then use event code or CF like that above but based on the checkbox value

    Hope that helps
    Last edited by isladogs; 02-06-2019 at 08:17 AM.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  5. #5
    BenHPieters is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Location
    Johannesburg
    Posts
    10
    Thank you, I simplified the field option to "completed" and "in progress" and using AfterUpdate (1) and your Case options, it works.
    Thanks for that.

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

Similar Threads

  1. Replies: 3
    Last Post: 01-26-2018, 03:25 AM
  2. Replies: 1
    Last Post: 10-06-2017, 12:14 PM
  3. Background colour when Form centered
    By jcc285 in forum Forms
    Replies: 4
    Last Post: 03-13-2015, 12:43 PM
  4. Replies: 2
    Last Post: 08-14-2013, 04:29 PM
  5. Change the colour of a form background
    By r_e_v_a_n_s in forum Forms
    Replies: 0
    Last Post: 11-15-2005, 03:39 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