Using a toggle button to change a label colour

atrodden

Registered User.
Local time
Today, 04:46
Joined
Jan 23, 2014
Messages
15
Hello all,

Is it possible to use a toggle button to change the colour of a label?

I assume the code should be something like this:

Code:
If Me.ToggleButton = 1 Then
Label.BackColor = RGB(0, 255, 0)
ElseIf Me.ToggleButton = 0 Then
Label.BackColor = RGB(255, 255, 255)
End If

But I've tried it in the "On Click" sections and it doesn't work.

Thanks in advance
 
Are you sure it is BackColor and not ForeColor? Also try debugging the code, see if the Click method is called, if so what is the value returned by the ToggleButton?
 
Yeah its definitely the back colour

Also try debugging the code, see if the Click method is called..

I don't what you mean by this though? :confused:

The toggle button has a value of either 1 or 0 though, with a Yes/No column in a table as its control source.
 
So, if you change the code as,
Code:
If Me.ToggleButton Then
    Label.BackColor = RGB(0, 255, 0)
Else
    Label.BackColor = RGB(255, 255, 255)
End If

Some Tips on Debugging in VBA
 
Still not working :(

If I use a macro then the label changes colour when the toggle is pressed but it reverts back when you leave the form and re-enter it.
 
Is the Back Style property of the Label set to Transparent rather than Normal?

If it is set to Transparent then it won't matter what colour you make it you would still see the colour of the form instead.
 

Users who are viewing this thread

Back
Top Bottom