Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Triple State    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Triple State Toggle Button
Tom Mura 
     
2 years ago
Is it possible to create something like a toggle button that has three states (Yellow, Green, Red)? I know that this won't work with a regular toggle button but thought it might be possible with VBA.
Adam Schwanz  @Reply  
           
2 years ago
Sure if you want to make your own toggle buttons, the skys the limit.
Adam Schwanz  @Reply  
           
2 years ago
On Click
And
If Then

Should cover most of what you would need.
Basically if its A move to B if its B move to C if its C go back to A
Tom Mura OP  @Reply  
     
2 years ago
Thanks Adam. What would I use as the 'button'? I want it to get its data from a field that is a triple state field called Returning.
Adam Schwanz  @Reply  
           
2 years ago
Just use a regular button, then control everything with vba. So your button would probably also set the caption of the button on press Caption so they knew what the current value was. And it would also set the value of your triple state field (which would probably be an invisible checkbox that stores the real value) A piece of your code would probably look like this. (Typing on phone doesnt put real double quotes  (apparently puts single quotes, use double) so dont just copy/paste this, wont work)

If mybutton.caption='a' then
    Mybutton.caption='b'
    Mycheckbox=false
Elseif mybutton.caption='b' then
    Mybutton.caption='c'
    Mycheckbox=null
Elseif mybutton.caption='c' then
    Mybutton.caption='a'
    Mycheckbox=true
End if
Tom Mura OP  @Reply  
     
2 years ago
Thanks Adam! That worked very well. My only issue now is that the button is on a continuous form and all of the buttons are changing together. The check box for each record is changing correctly using this code:
Private Sub ReturningBtn_Click()
    If ReturningBtn.Caption = "NO" Then
        ReturningBtn.Caption = "M"
        ReturningBtn.BackColor = RGB(255, 255, 0)
        ReturningCB = Null
    ElseIf ReturningBtn.Caption = "M" Then
        ReturningBtn.Caption = "Y"
        ReturningBtn.BackColor = RGB(0, 128, 0)
        ReturningCB = True
    ElseIf ReturningBtn.Caption = "Y" Then
        ReturningBtn.Caption = "NO"
        ReturningBtn.BackColor = RGB(255, 0, 0)
        ReturningCB = False
    End If
    
End Sub

Any way to have botton change independently for each record?
Tom Mura OP  @Reply  
     
2 years ago
Here's the solution I used to create a triple state toggle button. I use the checkbox (ReturningCB) with the Control Source set to the 'Returning' field and stretched it over a text box (ReturningTX). The check box is set to Triple State.

The control source of the text box is:
=IIf(IsNull([Returning]),"?",IIf([Returning]=-1,"Yes",IIf([Returning]=0,"No",[Returning])))

The conditional formatting of the text box looks like this sets the color to Yellow, Green or Red depending on whether the value is "?", "Yes" or "No".

I'll include an image of the result below.




Tom Mura OP  @Reply  
     
2 years ago

Tom Mura OP  @Reply  
     
2 years ago
I hope this helps someone else looking for a solution to a Triple State Toggle Button.
Tom Mura OP  @Reply  
     
2 years ago
I should say that I can click any where on the image of the button to change the value since the area of the checkbox stretched over the text box.
Tom Mura OP  @Reply  
     
2 years ago
I forgot to mention that you need to put Me.Requery in the After Update Event of the checkbox to get the update to show in a continuous form.

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

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: 4/30/2026 4:42:51 PM. PLT: 0s