locked
Access 2016: How can I change control properties (like color) in vba code ? RRS feed

  • Question

  • How can I change control properties (like color) in vba code ? 

    Form colors can easily be changed in form design view, where they are seen as Hex codes.  But vba only recognizes the old 8 digit color codes and not the new Hex color codes.

    I am updating an Access 2000 db to Access 2016, and want to use vba to loop thru the form controls to assign new colors.

    Thanks


    Richard Overturf MS Access developer Florida, USA

    Sunday, November 20, 2016 7:10 PM

Answers

  • You can use &H to specify a hexadecimal code:

    Me.SomeControl.BackColor = &HC0C0C0

    You can also use the RGB function to specify the red, green and blue components:

    Me.SomeControl.BackColor = RGB(64, 128, 192)


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Proposed as answer by Chenchen Li Monday, November 21, 2016 3:12 AM
    • Marked as answer by hds-rick Monday, November 21, 2016 6:14 PM
    Sunday, November 20, 2016 8:22 PM

All replies

  • You can use &H to specify a hexadecimal code:

    Me.SomeControl.BackColor = &HC0C0C0

    You can also use the RGB function to specify the red, green and blue components:

    Me.SomeControl.BackColor = RGB(64, 128, 192)


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Proposed as answer by Chenchen Li Monday, November 21, 2016 3:12 AM
    • Marked as answer by hds-rick Monday, November 21, 2016 6:14 PM
    Sunday, November 20, 2016 8:22 PM
  • Thanks !

    Richard Overturf MS Access developer Florida, USA

    Monday, November 21, 2016 6:14 PM