Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 134
  • Last Modified:

Change color on controls

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
check1
Asked:
check1
1 Solution
 
anthonycCommented:
Not all controls have a settable backcolor.....  commandbuttons being one of them unless the style is set to graphical!
0
 
DalinCommented:
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
 
DalinCommented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
DalinCommented:
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
 
SPECIALISTCommented:
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
 
check1Author Commented:
Thanks!

CHECK!
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now