Results 1 to 7 of 7
  1. #1
    matey56 is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jul 2020
    Posts
    136

    Format background of form based on single control

    I have a form with a control with numerical options 1-6. Depending on which number is selected in that control I want the background color of the entire form to change. Is that possible?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    in your option table, put optn# & color code:
    1, 255
    2, 4344566
    3, 7556343

    the combo will contain both columns ,but the user need only see 1 so set widths:
    .5;0

    then when user picks the item in combo, set the color:
    me.Detail.BackColor = cboBox (if col 2 is bound)

    if col1 is bound to combo:
    me.Detail.BackColor = cboBox.columns(1) 'in vba columns begin with 0

    these go in the AFTERUPDATE event:
    Code:
    sub cboBox_Afterupdate()
    
    me.Detail.BackColor = cboBox end sub



  3. #3
    matey56 is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jul 2020
    Posts
    136
    I guess there's no way to do it via Conditional Formatting?

  4. #4
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Not possible using conditional formatting. Textboxes and combos can be modified using CF but not other controls nor whole forms
    You have to use code
    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
    ssanfu is offline Master of Nothing
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I've don the following using SINGLE FORM MODE. I added a unbound text box control that covered the detail section. I sent it to the back and sent all of the controls to the front.
    I used CF to look at a specific control and set the BG of the text box using "Expression Is". Add as many rules as necessary.

    In this example the detail section BGis Green. Enter 5 and the text box switches to Yellow. I have 3 conditions =5, <5 and >5.


    In a continuous form, I added a text box that was bound to a boolean field so that if the field was TRUE, the text box BG would change. This was to high light which records were selected. If you use an UNBOUND text box in a continuous form.....
    well, try it and see what happens.


    Kinda clunky, but it might give you some ideas......
    Attached Files Attached Files

  6. #6
    matey56 is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jul 2020
    Posts
    136
    Quote Originally Posted by ssanfu View Post
    I've don the following using SINGLE FORM MODE. I added a unbound text box control that covered the detail section. I sent it to the back and sent all of the controls to the front.
    I used CF to look at a specific control and set the BG of the text box using "Expression Is". Add as many rules as necessary.

    In this example the detail section BGis Green. Enter 5 and the text box switches to Yellow. I have 3 conditions =5, <5 and >5.


    In a continuous form, I added a text box that was bound to a boolean field so that if the field was TRUE, the text box BG would change. This was to high light which records were selected. If you use an UNBOUND text box in a continuous form.....
    well, try it and see what happens.


    Kinda clunky, but it might give you some ideas......
    That works amazingly. Very simple too. Thanks!

  7. #7
    ssanfu is offline Master of Nothing
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Happy to help....

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

Similar Threads

  1. If Control Value is Modified - Format background
    By mike60smart in forum Forms
    Replies: 23
    Last Post: 01-01-2021, 03:05 PM
  2. Replies: 3
    Last Post: 01-26-2018, 03:25 AM
  3. Replies: 1
    Last Post: 10-06-2017, 12:14 PM
  4. Replies: 4
    Last Post: 08-29-2015, 07:38 AM
  5. Background Format
    By maysamab in forum Reports
    Replies: 7
    Last Post: 04-06-2009, 10:38 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