Solved

Change color on controls

Posted on 1998-09-01
6
132 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
Suggested Courses
Course of the Month11 days, 1 hour left to enroll

628 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