In my access I have 10 buttons which I have to change this colors according to some events. I want to not declare a RGB in all buttons
that is how I do:
Global greencolor As Variant
Public Function mp01()
greencolor = RGB(119, 221, 119)
Form_Frm_Processing.mp_02.BackColor = greencolor
End Function
Public Function mp02()
greencolor = RGB(119, 221, 119)
Form_Frm_Processing.mp_02.BackColor = greencolor
End Function
'-------------------------------------------------
that is how I want:
Global greencolor As Variant
greencolor = RGB(119, 221, 119)
Public Function mp01()
Form_Frm_Processing.mp_02.BackColor = greencolor
End Function
Public Function mp02()
Form_Frm_Processing.mp_02.BackColor = greencolor
End Function
CodePudding user response:
You're looking for a Const
:
Public Const greencolor As Long = 7855479
If you need to use a function, you can use a predeclared object. See this example. Note it will run the function each time the value is retrieved. That can be avoided by setting the values when initializing the object
CodePudding user response:
Try with:
Public greencolor As Long = 7855479 ' RGB(119, 221, 119)
Public Function mp01()
Form_Frm_Processing.mp_02.BackColor = greencolor
End Function
Public Function mp02()
Form_Frm_Processing.mp_02.BackColor = greencolor
End Function