Amend command button colours via public constants and load event of each form (1 Viewer)

chrisjames25

Registered User.
Local time
Today, 17:04
Joined
Dec 1, 2014
Messages
401
Doh i was doing so well. Not sure if this should be new thread or not as very related but i have now added the following code to do forecolor as well but it seems to make the box turn black not orange. If this not how you would type to change the forecolor:

Code:
Dim ctl As Control
For Each ctl In Me.Controls
      If ctl.Tag = "C" Then ctl.BackColor = ConButtonBackColor And ctl.ForeColor = ConButtonBackColor
Next

Appreciate i am turning forecolor and backcolor the same color in this example - not my final plan but was just testing code and sure the issue straightaway.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 10:04
Joined
Oct 29, 2018
Messages
21,358
Doh i was doing so well. Not sure if this should be new thread or not as very related but i have now added the following code to do forecolor as well but it seems to make the box turn black not orange. If this not how you would type to change the forecolor:

Code:
Dim ctl As Control
For Each ctl In Me.Controls
      If ctl.Tag = "C" Then ctl.BackColor = ConButtonBackColor And ctl.ForeColor = ConButtonBackColor
Next

Appreciate i am turning forecolor and backcolor the same color in this example - not my final plan but was just testing code and sure the issue straightaway.
You need to split them in two lines. For example:
Code:
If ctl.Tag="C" Then
    ctl.ForeColor=ConButtonBackColor
    ctl.BackColor=ConButtonBackColor
End If
 

chrisjames25

Registered User.
Local time
Today, 17:04
Joined
Dec 1, 2014
Messages
401
You need to split them in two lines. For example:
Code:
If ctl.Tag="C" Then
    ctl.ForeColor=ConButtonBackColor
    ctl.BackColor=ConButtonBackColor
End If
Perfect. Exactly what needed. Thank you all so much. Until next time i get stuck (knowing me a few hours)
 

theDBguy

I’m here to help
Staff member
Local time
Today, 10:04
Joined
Oct 29, 2018
Messages
21,358
Perfect. Exactly what needed. Thank you all so much. Until next time i get stuck (knowing me a few hours)
You're very welcome. We were all happy to assist. Good luck with your project.
 

mjdemaris

Working on it...
Local time
Today, 10:04
Joined
Jul 9, 2015
Messages
424
Just happened to stumble on this thread while looking for the same answer...
I created three long constants in a public module (Utilities), set values to RGB numbers: 100, 150, 200 for example.
Then created a public function
Code:
 ColorTest as Long
Code:
Public Function ColorTest() As Long
    ColorTest = RGB(c_Color1, c_Color2, c_Color3)
End Function
 

Users who are viewing this thread

Top Bottom