Results 1 to 4 of 4
  1. #1
    carterlangley is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2018
    Location
    Rothienorman, Scotland
    Posts
    15

    Change background colour of a form depending on option control state

    Hi guys,

    I have a "Yes/No" control on a form. When it is selected I need the forms background colour to change to red. Can somebody point me in the right direction please?

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Use code like this in the click or after update event for your control
    Code:
    if me.chkcontrolname=true then
    Me.Detail.Backcolor=vbBlue
    Else
    Me.Detail=vbCyan
    End if
    Replace control name and colors with your own
    You can use RGB values if you wish e.g. RGB(100,100,100) for one of 255 shades of grey (not 50)
    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
    carterlangley is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2018
    Location
    Rothienorman, Scotland
    Posts
    15
    Great thanks, that works on the form.
    Next question is I also have a navigation form which i used the built in menu to design. This navigation form is set as the default form to open when the database is opened. On selecting this particular form using the navigation form and I scroll through the listings, the control is selected but the background colour doesn't change.

  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
    I never use navigation forms as they can be awkward to modify.
    Try adding that code in Form_Current event as well
    Last edited by isladogs; 01-26-2018 at 07:04 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

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

Similar Threads

  1. Replies: 3
    Last Post: 02-16-2016, 10:32 AM
  2. Change Form Background Colour
    By Emma35 in forum Forms
    Replies: 11
    Last Post: 01-25-2016, 06:12 AM
  3. Replies: 3
    Last Post: 10-22-2015, 07:15 AM
  4. Background colour when Form centered
    By jcc285 in forum Forms
    Replies: 4
    Last Post: 03-13-2015, 12:43 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