Change color of control if selected

G

Guest

I am using a toggle button for yes/no questions on a form. I'd like the
color of the toggle button to change to a bright color if selected (it
currently changes to light grey which is barely noticeable). The Conditional
Formatting menu option is not available when I click on the control in design
view. Is there any other way to do this?
 
F

fredg

I am using a toggle button for yes/no questions on a form. I'd like the
color of the toggle button to change to a bright color if selected (it
currently changes to light grey which is barely noticeable). The Conditional
Formatting menu option is not available when I click on the control in design
view. Is there any other way to do this?

There is no built-in method to change the backcolor of a Toggle
button, however you can change the forecolor.
Try this.

Code the ToggleButton's Click event:

If Me.Toggle100.FontBold = False Then
Me.Toggle100.FontBold = True
Me.Toggle100.ForeColor = vbBlue
Else
Me.Toggle100.FontBold = False
Me.Toggle100.ForeColor = vbBlack
End If

Change Toggle100 to whatever the actual name of your toggle button is.
 
G

Guest

Thanks for the response. I tried putting this code into the 'OnClick' event
in the properties box of the control, but when I tried it out I get an error
message saying that there is no macro with that name. Do I need to create a
macro first? If so, I need some guidance.

Thanks!
 
F

fredg

Thanks for the response. I tried putting this code into the 'OnClick' event
in the properties box of the control, but when I tried it out I get an error
message saying that there is no macro with that name. Do I need to create a
macro first? If so, I need some guidance.

Thanks!

Let's start all over again.
Display the Toggle Button's Property sheet.
Click on the Event tab.
On the Toggle button's Click line, write:

[Event Procedure]

Then click on the little button with 3 dots that appears on that line.
When the code window opens, the cursor will be flashing between 2
already existing lines of code.
Between those 2 lines write the code I gave you.
Remember to change my generic Toggle100 to whatever the actual name is
of your toggle button.
When done, exit the code window to save the changes.

When you open the form and click on the Toggle button, the caption
will turn Bold and Blue.
When you next click on the button, it will return to black and not
bold.

You can change the colors to whatever other ones you wish.
 
G

Guest

Thank you so much - I've never done 'event procedure' before...I feel like a
whole new world of Access has opened up!


fredg said:
Thanks for the response. I tried putting this code into the 'OnClick' event
in the properties box of the control, but when I tried it out I get an error
message saying that there is no macro with that name. Do I need to create a
macro first? If so, I need some guidance.

Thanks!

Let's start all over again.
Display the Toggle Button's Property sheet.
Click on the Event tab.
On the Toggle button's Click line, write:

[Event Procedure]

Then click on the little button with 3 dots that appears on that line.
When the code window opens, the cursor will be flashing between 2
already existing lines of code.
Between those 2 lines write the code I gave you.
Remember to change my generic Toggle100 to whatever the actual name is
of your toggle button.
When done, exit the code window to save the changes.

When you open the form and click on the Toggle button, the caption
will turn Bold and Blue.
When you next click on the button, it will return to black and not
bold.

You can change the colors to whatever other ones you wish.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top