+ Reply to Thread
Results 1 to 8 of 8

Userform, black outline around button after use.

  1. #1
    Registered User
    Join Date
    03-24-2010
    Location
    Indiana
    MS-Off Ver
    Excel 2003
    Posts
    27

    Userform, black outline around button after use.

    I apologize if this has been answered before--I couldn't find it by searching. Anyway, I have a userform with several buttons. This userform resets after each submission and stays open 24/7! The last button to be pressed always gets a black outline around it. My users have told me that this confuses them (perhaps because when you see a button with a black outline, you should press it instead of the one you need???). Is there any way to get rid of this? I can post an image if necessary. Thanks!

  2. #2
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Userform, black outline around button after use.

    No need for a picture. What you need is for the focus of the click to go somewhere else other than the button. For instance, I did:
    Please Login or Register  to view this content.
    which removes the focus from the button as soon as it is clicked and then assigns the focus to the Label that I put into the userform. Does this make sense to you?
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  3. #3
    Forum Contributor
    Join Date
    07-27-2012
    Location
    California, USA
    MS-Off Ver
    Excel 2003
    Posts
    196

    Re: Userform, black outline around button after use.

    First I would look at the tab order of all the controls in the user form until I find the one that is assigned 0 (zero).
    If that control is a good one to get the focus when the form is not being used, I would make a note of its name,
    then I would edit the code behind each of the buttons that I don't want to be seen as the last one pressed, and
    at the end of each button's code insert, before the code exits, something like: Me.MyNumberOneControl.SetFocus
    and substitute the name of the control that was found to have a tab order of 0.

    If you find that a command button is assigned tab order 0 (zero), and it is one of the buttons you don't want to have
    shown as the last one pressed, then consider setting the focus to some other control that is not a button, maybe a
    text box if that is the first thing used on the form.

  4. #4
    Registered User
    Join Date
    03-24-2010
    Location
    Indiana
    MS-Off Ver
    Excel 2003
    Posts
    27

    Re: Userform, black outline around button after use.

    I actually do that already! I set the focus to the first textbox where the user will input data, though, instead of a label. It doesn't get rid of it...

  5. #5
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Userform, black outline around button after use.

    Can you upload an example?

    To Attach a File:

    1. Click on Go Advanced
    2. In the frame Attach Files you will see the button Manage Attachments
    3. Click the button.
    4. A new window will open titled Manage Attachments - Excel Forum.
    5. Click the Browse... button to locate your file for uploading.
    6. This will open a new window File Upload.
    7. Once you have located the file to upload click the Open button. This window will close.
    8. You are now back in the Manage Attachments - Excel Forum window.
    9. Click the Upload button and wait until the file has uploaded.
    10. Close the window and then click Submit.

  6. #6
    Registered User
    Join Date
    03-24-2010
    Location
    Indiana
    MS-Off Ver
    Excel 2003
    Posts
    27

    Re: Userform, black outline around button after use.

    Thanks for the help, but I can't upload a file. I have a textbox set as tab index zero. Using the command Me.Label1.SetFocus actually throws back an error. Somehow I don't even feel like the focus is the problem though. Each time I click one of the buttons, it gets a black outline until I click another...even after resetting all form variables. I forgot the mention..my option buttons are in a frame, and those buttons seem to be the only ones getting the black outline!

    edit: the black outline looks like the outline you get if you click and hold a command button, then move the mouse off of the button and release the mouse button. This is really annoying.
    Last edited by kortex; 10-03-2012 at 03:09 PM.

  7. #7
    Forum Contributor
    Join Date
    07-27-2012
    Location
    California, USA
    MS-Off Ver
    Excel 2003
    Posts
    196

    Re: Userform, black outline around button after use.

    I was thinking of command buttons, but your problem is with option buttons in a frame.
    If you go into form form design mode and double-click on each of the option buttons to view
    the Click Event code, that is where you can move the focus away from that button and
    to a text box.

    I often use a gimmick to make it look like nothing on the form has the focus, by adding a command
    button with a height of 1 and width of 1. I name it cmdDummy and position it inside one of the
    form's larger command buttons.
    The nearly-invisible cmdDummy object gets the focus, alter the click of an option button,
    check box, or command button, and the form looks clean, not showing what was pressed last.

  8. #8
    Registered User
    Join Date
    03-24-2010
    Location
    Indiana
    MS-Off Ver
    Excel 2003
    Posts
    27

    Re: Userform, black outline around button after use.

    xlJer,

    I made a cmdDummy command button and set its width, height, top and left to zero. After each button is clicked and the script is done running, I set the focus to cmdDummy and then to the textbox. There is no more black outline! Thank you so much. Now the users will (most likely....) click the right buttons!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1