Results 1 to 11 of 11
  1. #1
    Join Date
    Mar 2004
    Location
    Greenville, SC
    Posts
    271

    Unanswered: highlight a check box

    Is there code I can write that would let me highlight (or change the background) (or change text color) when the checkbox is selected. I know conditional formatting will not work!

    Any help is greatly appreciated!
    Michael
    Gotta to do some code

  2. #2
    Join Date
    Mar 2004
    Location
    San Diego
    Posts
    45
    in the after update event of the check box, you can set the color. The color would only change when the value changed.

    checkboxName.forecolor=blue

    ....for example

  3. #3
    Join Date
    Mar 2004
    Location
    Greenville, SC
    Posts
    271
    Right now when the user goes to this control, they have no idea where they are. I have all other controls highlighted yellow using conditional formating. That way they know exactly where their cursor is on the form.

    As soon as the control has "got focus", The background should change color. Is there a way??????

    Michael
    Gotta to do some code

  4. #4
    Join Date
    Mar 2004
    Location
    San Diego
    Posts
    45
    You would just put the code to change the color in the got focus event, in that case. Then, when they clicked the box or tabbed into it, it would change color.

    so,

    yourtextbox.backcolor=color

    Instead of forecolor, as I posted earlier, it is backcolor to change the box itself.

    Does that make sense? Post back it you need more help!

    Hope this helps!

  5. #5
    Join Date
    Mar 2004
    Location
    Greenville, SC
    Posts
    271
    Here is how I entered the code.

    Private Sub NoChargeWO_GotFocus()
    [NoChargeWOLabel].BackColor = yellow
    End Sub

    What am I missing. I am very new to code. Excuse the ignorance

    michael
    Gotta to do some code

  6. #6
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    1 question, 1 tip


    1. Are you wanting the actual checkbox to turn yellow? or the Check box label?

    2. You dont need the brackets you have surrounding the label name.

    hope this helps some,
    JS
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

  7. #7
    Join Date
    Mar 2004
    Location
    San Diego
    Posts
    45

    Post

    Okay, I got it. I didn't test that last bit. This worked for me:

    Code:
    Private Sub NoChargeWO_GotFocus()
    
        Dim lngYellow as Long
        lngYellow = RGB(255, 255, 0)
    
        Me!NoChargeWOLabel.BackColor = lngYellow
    
    End Sub
    Let me know if this works.

  8. #8
    Join Date
    Mar 2004
    Location
    Greenville, SC
    Posts
    271

    Thumbs up

    Yes! That did it! Thank You
    It was not working because I had the back style set to transparent. As soon as I changed it, it worked.

    What could I write say..... in the on exit command to set it back to the color I had (63, 224, 135)

    Thank you soooooooooo much
    Michael
    Gotta to do some code

  9. #9
    Join Date
    Mar 2004
    Location
    San Diego
    Posts
    45

    Talking

    Essentially do the same thing, except declare another variable if your color is uncommon. You can also use the color constants if the background is a standard color.

    so using vbWhite, it would be

    Me!NoChargeWOLabel.BackColor = vbWhite

    These are the constant colors you can use without having to declare an RGB():

    vbBlack
    vbRed
    vbGreen
    vbYellow
    vbBlue
    vbMagenta
    vbCyan
    vbWhite

    You could go ahead and use the vbYellow if you want instead of my example code.


    Does that help?

  10. #10
    Join Date
    Mar 2004
    Location
    Greenville, SC
    Posts
    271
    I got it!
    I copied the code exactly and put it under the "On Exit" and it works great. I changed the RGB to 63, 224, 135 and it worked perfectly.

    I want to thank you. I am really trying to learn code. I wish there was a reference that had all or many possibilities for entering or manipulating properties as I wanted to do with colors.
    I try to use help as often as possible. I could get it to give me what you helped provide.

    Thank you so much again! I know I am green when it comes to code, but maybe I can help you one day!

    Michael
    Gotta to do some code

  11. #11
    Join Date
    Mar 2004
    Location
    San Diego
    Posts
    45
    No problem!! I am glad to help, as I too am fairly green and ask a ton of questions, so I like to give back whenever I can.

    Yay! It feels so good when something WORKS!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •