+ Reply to Thread
Results 1 to 7 of 7

Highlight Erroneous Text In Textbox To Be Overwritten

  1. #1
    Forum Contributor
    Join Date
    06-15-2009
    Location
    Ontario, canada
    MS-Off Ver
    Office 365
    Posts
    371

    Highlight Erroneous Text In Textbox To Be Overwritten

    I have a text box (empl_no2) in my userform. If the user enters an inappropriate value, I want error to code to reset the default value ("00000") and then highlight it to allow the user to overwrite it.

    This has worked for me in the past, but for some reason this time it's not. It isn't highlighting the text.

    Please Login or Register  to view this content.
    Last edited by Jenn68; 02-28-2019 at 09:28 PM.

  2. #2
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Highlight Erroneous Tex In Textbox To Be Overwritten

    How about this..
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Highlight Erroneous Tex In Textbox To Be Overwritten

    This codes works for me. What module has this code? What sub? Do you see the MsgBox?

    In cases like this, people often trace an error to the wrong place and so they post something very narrowly focused, we scratch our heads over it, later realizing the problem was somewhere else entirely. Consider attaching your file, with private data removed. The paper clip icon does not work for attachments. To attach a file, under the text box where you type your reply click the Go Advanced button. On the next screen scroll down and click on Manage Attachments, which will show a pop-up window to Select and Upload a file. Then close the window.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  4. #4
    Forum Contributor
    Join Date
    06-15-2009
    Location
    Ontario, canada
    MS-Off Ver
    Office 365
    Posts
    371

    Re: Highlight Erroneous Text In Textbox To Be Overwritten

    Thank you both for your support,

    Bakerman, I have intentions of tring out your suggestion, I just haven't yet as from posting the whole module, as Jeff mentioned, there may be more to the problem than what was simply posted originally.

    Here is the entire module ... (yes, I'm certain it can be streamlined, and perhaps Bakerman's suggestion is all emcompassing)

    Please Login or Register  to view this content.
    It will take me considerable time to sterilize my application to provide publically. Perhaps with the whole module being posted the problem is more visible and posting the file will be unnecessary. And yes ... I do see the msgbox.

  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Highlight Erroneous Text In Textbox To Be Overwritten

    I will continue to look at this but have reproduced your problem. Even though focus is set to the textbox, as soon as the Sub exits, focus shifted to my Close button even though there is no code to do that.

  6. #6
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Highlight Erroneous Text In Textbox To Be Overwritten

    Jeff, I think I've experienced that behaviour in the past and my best guess it's the AfterUpdate -event that's responsible for that.

    AfterUpdate already moves the focus, so the code will be executed but the SetFocus of the textbox is overridden by the AfterUpdate.

  7. #7
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Highlight Erroneous Text In Textbox To Be Overwritten

    Excellent observation. When using the Exit event (and setting Cancel to True) this works perfectly.
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Highlight textbox if date <=60 days referencing an array as textbox numbers
    By nigelog in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 03-23-2017, 11:43 AM
  2. [SOLVED] Highlight overwritten cells
    By Trebor777 in forum Excel General
    Replies: 7
    Last Post: 09-22-2016, 07:45 AM
  3. Highlight Textbox Text during a loop
    By Lardman363 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-19-2015, 07:49 AM
  4. Highlight text within a textbox
    By jpruffle in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-07-2009, 02:30 PM
  5. highlight text in userform textbox
    By RB Smissaert in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-02-2005, 07:50 PM
  6. [SOLVED] highlight text in userform textbox
    By RB Smissaert in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-02-2005, 06:17 PM
  7. Highlight all Text in a Textbox when the textbox is selected
    By RPIJG in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-28-2005, 03:28 PM

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