Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Toggle Buttons
Ronald Bella 
     
2 years ago
I have placed multiple Toggle Buttons on a form to replace check boxes because I wanted to use the Triple State property and have three states, Yes, No, Skip.   Thus if a question is answered Yes, I want the toggle to be green and say, Yes.  If no, I want the toggle to turn red and say, No.  If the question is not asked, I want the toggle to be blue and say Skip.   Access seems to have a mind of its own re colors. I have given it instructions to change name and change color and use bold white font and even though VBA says Yes, No, Skip.   The font is bright white for Yes and No and grayish for Skip.  The colors do not change green, red, blue but instead are Blue, Red, Light Blue.   Is there a way to wrestle control from Access properties on the toggle button and get the colors and font I want?
Kevin Robertson  @Reply  
          
2 years ago
Have you set the Use Themes property to No?
Ronald Bella OP  @Reply  
     
2 years ago
Yes
John Davy  @Reply  
         
2 years ago
Hi Ronald
You said "I have given it instructions to change name and change color and use bold white font and even though VBA says Yes, No, Skip.  ". It would help for us to see those instructions.

John
Ronald Bella OP  @Reply  
     
2 years ago
DetailsPrivate Sub Q_1_1_Click()
    If Me.Q_1_1 = -1 Then
        Me.Q_1_1 = 0 ' No
        Me.Q_1_1.Caption = "NO"
        Me.Q_1_1.BackColor = RGB(255, 0, 0) ' Bright red
        Me.Q_1_1.ForeColor = RGB(255, 255, 255) ' Bright white
    ElseIf Me.Q_1_1 = 0 Then
        Me.Q_1_1 = Null ' Skip
        Me.Q_1_1.Caption = "SKIP"
        Me.Q_1_1.BackColor = RGB(0, 0, 255) ' Bright blue
        Me.Q_1_1.ForeColor = RGB(255, 255, 255) ' Bright white
    ElseIf IsNull(Me.Q_1_1) Then
        Me.Q_1_1 = -1 ' Yes
        Me.Q_1_1.Caption = "YES"
        Me.Q_1_1.BackColor = RGB(0, 255, 0) ' Bright green
        Me.Q_1_1.ForeColor = RGB(255, 255, 255) ' Bright white
    End If
End Sub

Kevin Robertson  @Reply  
          
2 years ago
First, consider giving your Toggle Button a more descriptive name.
If the Forecolor isn't changing you can just set it at design time.
You don't need to repeat the Me keyword for fields on the current form.
Put the Null as an Else condition.

    If ToggleButtonName = True Then
        ToggleButtonName.Caption = "YES"
        ToggleButtonName.BackColor = RGB(0, 255, 0)
    ElseIf ToggleButtonName = False Then
        ToggleButtonName.Caption = "NO"
        ToggleButtonName.BackColor = RGB(255, 0, 0)
    Else
        ToggleButtonName.Caption = "SKIP"
        ToggleButtonName.BackColor = RGB(0, 0, 255)
    End If


I would put this code in the After Update event.
Ronald Bella OP  @Reply  
     
2 years ago
Thank you Kevin for taking the time to respond.   Given today is Sunday, I won't be able to test your suggestions until tomorrow.   The name is one of about forty similar names that represent questions, page and section of multiple forms.  Thus, it is targeted to describe the specific question being asked and answered.   I do have the forecolor property set to white in the design.   I can certainly change those other things.   I am particularly curious about the after update event move from on click.   I have tried this in multiple variations but always on click.    I tried using vbGreen instead of RGB codes.  I tried theme off and on.   I tried deleting the assigned background colors but colors always sprang back.  Colors may have changed but never to the desired color I want after testing.  Thank you again.   I will post results tomorrow.  Best.
Ronald Bella OP  @Reply  
     
2 years ago
Unfortunately, the move from On Click to After Update did nothing for the situation.   I also tested it After Update by setting No to the Theme but all that did was change the color of the toggle to white, white, and white.   Unless someone can give Access a pill to cure it of this phobia it has for green toggle buttons, I will resign myself to blue, red and blue which is far better than white, white and white.  Thank you Kevin for your suggestions.
Matt Hall  @Reply  
           
2 years ago
Try not setting the button value.  Let it toggle itself.  

For the -1 value, try using the pressedcolor and pressedbackcolor options like this:

ElseIf Me.Q_1_1 = -1 Then
    Me.Q_1_1.Caption = "YES"
    Me.Q_1_1.PressedColor = RGB(0, 255, 0) ' Bright green
    Me.Q_1_1.PressedForeColor = RGB(255, 255, 255) ' Bright white


For the 0 and Null states, you can try changing the hover color as well if you like that look.

You may be stuck with light gray forecolor for the NULL state.
Ronald Bella OP  @Reply  
     
2 years ago
Matt.   Thank you.    Oddly, your PressedColor property worked for the green but not for the Blue or Red.  However, that doesn't matter.   I simply left their BackColor property as it was and used the PressedColor property for my green.   It works now as I wanted.
Matt Hall  @Reply  
           
2 years ago
The PressedColor seems to be the ON color for the toggle -- only when the toggle has a True value (-1) -- and the BackColor is the OFF color for the toggle.  Your toggle is only ON during your "green" condition.

FWIW, I usually use Labels, to do what you have described. Sometimes, Buttons, if I need the extra function like gradient and shape properties.   You have already done all of the work in your code.  Just evaluate the label/button caption to trigger your if statements.

If Me.Q_1_1.Caption = "YES" Then

Glad to help

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/26/2026 11:29:10 AM. PLT: 0s