Results 1 to 7 of 7
  1. #1
    Join Date
    Jun 2005
    Posts
    102

    Unanswered: Moving from 1 txtBox to another.

    I have 4 unbound text boxes (txt1, txt2, txt3, and txtAll)... On the Control Source of txtAll, this expression is written =[txt1] & [txt2] & [txt3], and the control (txtAll) is not enabled. Whatever the user inputs on txt1-3, it gets concatenate together and goes in txtAll.

    The problem I have is, when the user has entered data in txt1 (5 characters maximum), the cursor stays on txt1. I want it to move to txt2 automatically and when the user input 3 characters in txt2, it should move to txt3, but instead the user has to press Tab key to move through the fields. How can I fixed this.
    The only true wisdom is in knowing you know nothing.

  2. #2
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,424
    Provided Answers: 8
    Look @ the Keypress

    [CODE]
    Private Sub txt1_KeyPress(KeyAscii As Integer)
    If Len(txt1) > 5 Then
    txt2.SetFocus
    End If
    End Sub

    Private Sub txt2_KeyPress(KeyAscii As Integer)
    If Len(txt2) > 3 Then
    txt3.SetFocus
    End If
    End Sub
    [\CODE]
    hope this help

    See clear as mud


    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB based on my own environment: vb6 sp5
    ASP based on my own environment: 5.6
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    MYLE
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.

  3. #3
    Join Date
    Jun 2005
    Posts
    102
    It still doesn't move to the next box after I type 3 characters in txt2..
    The only true wisdom is in knowing you know nothing.

  4. #4
    Join Date
    Jun 2005
    Posts
    102
    I've also tried changing the operator from Greater Than to Equal To (e.g. If Len(txt1) = 5 Then)... But it still doesn't move to the next box, after 5 characters are inputted.
    The only true wisdom is in knowing you know nothing.

  5. #5
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Personally I'd use the change event, but the keypress event may work fine. The key in either case is that you have to specify the Text property of the control. Since it hasn't been updated, the Value property (the default) does not yet contain what's being typed.
    Paul

  6. #6
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,424
    Provided Answers: 8
    If Len(txt1.text) > 5 Then
    txt2.SetFocus
    End If

    try the .text and the end what part of the object are we testing
    sorry had the wrong hat on been in asp(vbscript) for a couple of days
    hope this help

    See clear as mud


    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB based on my own environment: vb6 sp5
    ASP based on my own environment: 5.6
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    MYLE
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.

  7. #7
    Join Date
    Jun 2005
    Posts
    102
    Okay, it works now, thanks guys!
    The only true wisdom is in knowing you know nothing.

Posting Permissions

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