Solved

Change color on controls

Posted on 1998-09-01
6
128 Views
Last Modified: 2010-04-30
With the commondialog control I want to change the colors of command buttons, labels, etc.  The code I was given works great for fonts but I get error messages when i apply it to colors.

Form3!dlg.ShowColor

Dim myControl As CommandButton'  this does not work even If I put control or label here!


On Error GoTo Trap
For Each myControl In Form1
   
myControl.BackColor = Form3!dlg.Color

Next
   'Exit here
Trap:
     Err.Clear
   Resume Next

thanks
0
Comment
Question by:check1
6 Comments
 
LVL 6

Expert Comment

by:anthonyc
ID: 1432406
Not all controls have a settable backcolor.....  commandbuttons being one of them unless the style is set to graphical!
0
 
LVL 9

Expert Comment

by:Dalin
ID: 1432407
check1,
you have an error before the code "on error goto ..."

Form3!dlg.ShowColor should be form3.dlg.showcolor?

Dim myControl as Control is OK.

What error message you get?

0
 
LVL 9

Expert Comment

by:Dalin
ID: 1432408
What anthonyc said is true... But it is OK because of your errortrapping. When no back color, error occurs, and it will automatically clear the error and goto the next control.
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 9

Accepted Solution

by:
Dalin earned 30 total points
ID: 1432409
check1,
I just tried this and it works.
Drop a command in form1 and name it command1

Private Sub Command1_Click()

Form3.cdg.ShowColor

Dim myCOntrol As Control

On Error GoTo Trap

For Each myCOntrol In Form1
    myCOntrol.BackColor = Form3.cdg.Color
    Next
Exit Sub
   
Trap:
    Err.Clear
    Resume Next
   
End Sub

0
 
LVL 3

Expert Comment

by:SPECIALIST
ID: 1432410
I don't know, I can just say If I use the same code for fonts it works, let me try you suggesion.

Check1
0
 

Author Comment

by:check1
ID: 1432411
Thanks!

CHECK!
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question