Solved

Change color on controls

Posted on 1998-09-01
6
127 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

943 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now