Results 1 to 6 of 6
  1. #1
    uoghk is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jan 2022
    Posts
    149

    change button backcolor

    By default, a button backcolor is "Accent 1, Darker 25%" as below photo.
    Click image for larger version. 

Name:	螢幕擷取畫面 2023-06-08 093635.png 
Views:	28 
Size:	49.7 KB 
ID:	50331
    I use code to change btnAllergy backcolor
    If I set Me.btnAllergy.BackColor = "Accent 1, Darker 25%", then it returns error.
    Then I set Me.btnAllergy.BackColor = Me.btnExit.BackColor, but it shows as below photo.
    Click image for larger version. 

Name:	螢幕擷取畫面 2023-06-08 093801.png 
Views:	27 
Size:	25.3 KB 
ID:	50332

  2. #2
    Edgar is online now Competent Performer
    Windows 8 Access 2016
    Join Date
    Dec 2022
    Posts
    274
    If you do this:
    Code:
    Msgbox "VBA says the allergy button's back color is: " & Me.btnAllergy.BackColor & vbcrlf & "And the exit button's back color is: " & Me.btnExit.BackColor
    Does it give you any idea?

  3. #3
    uoghk is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jan 2022
    Posts
    149
    Thanks Edgar.
    Actually I want to set the Allergy button's backcolor as same as the Exit button (which is light blue).
    But when run the code
    Code:
    Me.btnAllergy.BackColor = Me.btnExit.BackColor
    The Allergy button's backcolor becomes dark blue as in the second photo.

  4. #4
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,651
    Code:
    Me.btnAllergy.BackColor = Me.btnExit.BackColor
    Odd. Only seems to work if "Use Themes" property is set to yes.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  5. #5
    uoghk is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jan 2022
    Posts
    149
    thanks moke123.
    the btnAllergy already Use Themes

  6. #6
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,651
    if you look at the color picker you can get the RGB values. Then use the RGB() to set your color.

    Code:
    me.MyControlName.BackColor = RGB(178,240,196)
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

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

Similar Threads

  1. Replies: 13
    Last Post: 03-23-2023, 12:36 PM
  2. Replies: 2
    Last Post: 08-26-2019, 10:51 AM
  3. Replies: 7
    Last Post: 08-23-2014, 05:52 AM
  4. If/Else If help to Change BackColor
    By SpdRacerX in forum Access
    Replies: 2
    Last Post: 03-20-2012, 10:09 AM
  5. Replies: 1
    Last Post: 10-22-2009, 03:32 AM

Tags for this Thread

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