CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    May 2009
    Location
    London
    Posts
    51

    Unhappy Validation Event

    HELP!

    Not sure if there is a possible solution for this one but here goes.....

    I have a form which is used for creating/editing invoices. The first control that gains the focus is a text box for the invoice number. The user has the option to enter an existing invoice number or press one of two buttons by the side of it ([New Invoice] and [Find Invoice]). There are an assortment of other controls on the form for the invoice details.

    All Fine So Far.

    The problem that I have is that I use the Validate event of the Invoice Number Text Box to check whether or not the invoice number entered is valid. I do not want the user to move to any of the other controls unless a valid invoice number is entered except for the Find Invoice and New Invoice Buttons. Within the Validate event I need to know which control the focus is trying to move to. The form ActiveControl property is still pointing to the invoice number text box as the focus does not move until after the Validate event completes.


    Any Ideas?

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Validation Event

    Get rid of that, and use the LOST FOCUS event, as well as the key presses (to track ENTER/TAB) and then do your own validation.

    It will work better, because it will work the way that you WANT
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    May 2009
    Location
    London
    Posts
    51

    Smile Re: Validation Event

    Thanks Dglienna, found solution, I didn't know that the CausesValidation event applies to the control that receives the focus so this does the job fine. I tried using the LostFocus event but that seems to interfere with the Click event of the button (button receives focus but no Click event fires).

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Validation Event

    Trap what you need to.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

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

Featured