Results 1 to 8 of 8

Thread: EASY question regarding validating a text box

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2001
    Location
    New Zealand
    Posts
    268

    EASY question regarding validating a text box

    Hello

    I have a text box, lets call it txtBob. When the user enters something in txtBob and leaves the field I have some validation that checks the data is good.

    What I want... is when the data is not good, a message comes up saying "Bad data BAD", I've got this far. Then I also want the cursor to stay in that box (i.e. not tab to the next text box).

    I tried putting it on the exit sub for txtBob, but then unfortunately it becomes stuck in that box (i.e. the user cant click the cancel because it keeps checking the text box).

    Is there a way, I can have the message and cursor stay in txtBob, while still allowing the user to click into another field/button.

    Thanks heaps for you help
    Ange

    P.S. <- what a strange Smiley

  2. #2

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2001
    Location
    New Zealand
    Posts
    268

    Re: EASY question regarding validating a text box

    Thanks MartinLiss!

    Unfortunately we dont appear to have a validate event on our text box. It could be because we are using VB version 97?

    Any other ideas?

    Thanks again
    Ange

  4. #4

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2001
    Location
    New Zealand
    Posts
    268

    Re: EASY question regarding validating a text box

    Yes! Sorry.. VBA 97

  6. #6
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: EASY question regarding validating a text box

    Try the TextBox1_Exit Sub:
    VB Code:
    1. Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    2.  
    3. End Sub

  7. #7

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2001
    Location
    New Zealand
    Posts
    268

    Re: EASY question regarding validating a text box

    Hi

    Sub TextBox1_Exit() does the trick, the chap I was helping out got me confused. We had it all along, duh.

    Thanks all
    Ange


    Weird frogs...

Posting Permissions

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



Click Here to Expand Forum to Full Width