Results 1 to 11 of 11

Thread: Validation problem [RESOLVED]

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2005
    Posts
    10

    Resolved Validation problem [RESOLVED]

    Hello everyone,

    I need a way to avoid that a clicked control gets the control, is there a way to do it ?

    This is my case, I have a text box that the only valid values are the ones that exists in a data combo, but I need to give the control to the data combo when the value in the text box is incorrect and retain the control until the user select a correct value.

    Right now I can do it when I manually run the textbox1_validate event (in the keyup event), but when the user uses tab key or mouse to move to another control, I can not trap the control in the data combo.

    I am using the cancel variable in the validate event, but does not work because then I can not go to the data combo,

    Thanks
    Last edited by rodrvars; Apr 19th, 2005 at 01:57 PM. Reason: RESOLVED

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Validation problem

    There is also the Lost_Focus property that you can use.

  3. #3
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011

    Re: Validation problem

    Quote Originally Posted by rodrvars
    Hello everyone,

    I need a way to avoid that a clicked control gets the control, is there a way to do it ?

    This is my case, I have a text box that the only valid values are the ones that exists in a data combo, but I need to give the control to the data combo when the value in the text box is incorrect and retain the control until the user select a correct value.

    Right now I can do it when I manually run the textbox1_validate event (in the keyup event), but when the user uses tab key or mouse to move to another control, I can not trap the control in the data combo.

    I am using the cancel variable in the validate event, but does not work because then I can not go to the data combo,

    Thanks
    Just a thought... don't u have a textbox with a datacombo? why do u need to add a separate textbox?

    and you can also code in Text1_Validate Event.. just don't use cancel... rather.. you can use If Text1 is not valid then dbcombo1.SetFocus... and on datacombos validate event you can set cancel = true if the textbox is still not valid..

  4. #4

    Thread Starter
    New Member
    Join Date
    Apr 2005
    Posts
    10

    Re: Validation problem

    Thanks Dglienna and Moinkan.

    Dglienna, I am gonna try to use the lostfocus event, but I don't know if over there I can use setfocus.

    Moinkan, I am using the text and the data grid (exucuses, not datacombo) to simulate a multicolumn combobox, and Rigth now I am doing the same thing that you told me but, when the user click on other control the datagrid doesn't keep the control.

    Thanks again

  5. #5
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Validation problem

    VB Code:
    1. text1.setfocus
    works!

  6. #6

    Thread Starter
    New Member
    Join Date
    Apr 2005
    Posts
    10

    Re: Validation problem

    Dglienna,

    When I try to give the focus on the lostfocus event I got an error :

    Run-time error '5':
    Invalid procedure call or argument

    This is the event code :

    Private Sub MyFlexGrid_LostFocus()
    If Not m_Status_Val Then
    MyFlexGrid.SetFocus
    End If
    end sub

    The m_status_val is the boolean var that says if the value is valid or not

    Thanks

  7. #7
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Validation problem

    You have to supply the cell to focus on.
    VB Code:
    1. MyFlexGrid.textmatrix(r,c).SetFocus

  8. #8
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Validation problem

    DG - I've never seen setting the focus to a particular cell - do you really use that?

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  9. #9

    Thread Starter
    New Member
    Join Date
    Apr 2005
    Posts
    10

    Re: Validation problem

    Dglienna,

    I am using DataGrid, so that TextMatrix property does not exists

  10. #10
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Validation problem

    Quote Originally Posted by szlamany
    DG - I've never seen setting the focus to a particular cell - do you really use that?

    hmmm. it looked right at the time, but I was thinking of the floating textbox rather than the cell. sorry about that.

    Not sure about the datagrid. I don't think you can specify individual cells. that's why I assumed that it was a flexgrid.

  11. #11
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Validation problem

    Just a crazy thought, but why don't you use SetCapture when you want to lock out all other controls and ReleaseCapture when you don't?
    VB Code:
    1. Option Explicit
    2. Private Declare Function SetCapture Lib "user32" ( _
    3.     ByVal hwnd As Long _
    4. ) As Long
    5.  
    6. Private Declare Function ReleaseCapture Lib "user32" ( _
    7. ) As Long
    To set capture to your datagrid just call
    VB Code:
    1. SetCapture DataGrid1.hwnd
    and to release it
    VB Code:
    1. ReleaseCapture

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