Consulting

Results 1 to 10 of 10

Thread: tab inside of text box? or just a "bug" ?

  1. #1

    tab inside of text box? or just a "bug" ?

    hi all.

    I have a unique "bug" i think. i have created a form in excel that has multi text boxes in it. in each of these text boxes, i have a check to ensure that they only key in 0-9. it looks kinda like this

    Gross * Net
    |--txtbox--| |--txtbox--| prod 1
    .
    .
    .
    |--txtbox--| |--txtbox--| prod 5

    they way it is suppose to work, is they key in a value for gross prod (1). it will then allow them to key in a value for net prod (1) and if they hit tab it will tab TO net prod (2) box. if they do not enter a value in gross prod (1), a tab will go to gross prod (2) all the way through five.

    a user stated that when they key in a value for gross/net prod (1), they tab and it goes to gross(2) {which is correct}. they key in a value for gross prod (2) and when they hit the tab key, it TABS inside that box (like a tab indent).

    i ran the orginal .xls from my end, followed what they did and got the same result. i opened up the debugger, walked through all the events related, saw no problems. closed out the debuggger window and it worked fine till prod (5). repeated same process again with debugger and again changed NOTHING. i exited excel, opened file and ran app with NO issues this time!

    any ideas on what might be the "issue" if any???

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Can you post your code, I am not seeing it.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Quote Originally Posted by xld
    Can you post your code, I am not seeing it.
    sure here is a set of code for one of the boxes. they are all pretty much the same. does this help?




    '******************************************************

    Private Sub txtGross1_Exit(ByVal Cancel As MSForms.ReturnBoolean)

    If txtGross1.Value = 0 Then
    MsgBox ("You must key in some value other than multiple zeros")
    txtGross1.Text = ""
    txtNet1.Enabled = False
    txtGross1.SetFocus
    Exit Sub
    End If
    End Sub

    '******************************************************

    Private Sub txtGross1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)

    ' just checks to make sure user keys in proper values.

    Select Case KeyAscii


    Case 48 To 57 ' for number 0-9
    txtUnl1.Enabled = True
    Case Else
    MsgBox "Only numericals are allowed"
    KeyAscii = 0
    End Select
    End Sub

    '******************************************************

  4. #4
    VBAX Mentor tstav's Avatar
    Joined
    Feb 2008
    Location
    Athens
    Posts
    350
    Location
    any ideas on what might be the "issue" if any???
    Quoted by:wolf.stalker
    I came across the same issue some weeks ago. After writing something in a textbox, tabbing would not take me to the next textbox in the Form, but rather it would tab inside the same text box.
    The catch is that this only happend on PCs running on Windows NT 4.0. When the same code ran on PCs with Win2000 or WinXP, tabbing worked as expected (jumped from text box to textbox).
    I didn't try to find a solution to this, since we scarcely use the WinNT PCs.
    I'm just telling you what caught my attention, just in case...

  5. #5
    VBAX Mentor tstav's Avatar
    Joined
    Feb 2008
    Location
    Athens
    Posts
    350
    Location
    wolf.stalker, check this code to see if it suits your needs.
    I have substituted your _keypress and _exit events with only the following _keyDown event.

    [vba]Private Sub txtGross1_KeyDown _
    (ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    Select Case KeyCode
    'Allow only digits and Del,Left,Right,Backspace,Home,End keystrokes
    Case vbKey0, vbKey1, vbKey2, vbKey3, vbKey4, vbKey5, vbKey6, vbKey7, vbKey8, vbKey9, _
    vbKeyNumpad0, vbKeyNumpad1, vbKeyNumpad2, vbKeyNumpad3, vbKeyNumpad4, _
    vbKeyNumpad5, vbKeyNumpad6, vbKeyNumpad7, vbKeyNumpad8, vbKeyNumpad9, _
    vbKeyDelete, vbKeyLeft, vbKeyRight, vbKeyBack, vbKeyHome, vbKeyEnd
    'If tab, act accordingly
    Case vbKeyTab
    KeyCode = 0
    If txtGross1.Value = 0 Then
    MsgBox ("You must key in some value other than multiple zeros")
    txtGross1.Text = ""
    txtGross1.SetFocus
    ElseIf txtGross1.Value = "" Then
    txtGross2.SetFocus
    End If
    'Else alert the user
    Case Else
    KeyCode = 0
    Beep
    End Select
    End Sub
    [/vba]
    Last edited by tstav; 02-24-2008 at 12:29 PM.

  6. #6
    hmm, i can try that which i have no problem doing...but my question still remains...is my problem a bug or what?

  7. #7
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    It sounds like the .TabKeyBehaviour property of the TextBox is set to True.

  8. #8
    VBAX Mentor tstav's Avatar
    Joined
    Feb 2008
    Location
    Athens
    Posts
    350
    Location
    Yes mikerickson, it does sound a lot like the .TabKeyBehavior property.
    Still, I'm pretty much sure that even though the property was set to false, it acted as if it was set to true, ONLY on a WinNT machine.
    I may be able to retest it tomorrow. If I do, I'll get back to you.
    He didn't know it was impossible, so he did it. (Jean Cocteau)

  9. #9
    Quote Originally Posted by tstav
    I came across the same issue some weeks ago. After writing something in a textbox, tabbing would not take me to the next textbox in the Form, but rather it would tab inside the same text box.
    The catch is that this only happend on PCs running on Windows NT 4.0. When the same code ran on PCs with Win2000 or WinXP, tabbing worked as expected (jumped from text box to textbox).
    I didn't try to find a solution to this, since we scarcely use the WinNT PCs.
    I'm just telling you what caught my attention, just in case...
    tstav:

    sorry, i missed this post but saw the one for the code. it sounds like this is just an odd behavior for NT?.

  10. #10
    VBAX Mentor tstav's Avatar
    Joined
    Feb 2008
    Location
    Athens
    Posts
    350
    Location
    wolf.stalker:it sounds like this is just an odd behavior for NT?
    Like I said, I will try to re-test this on a WinNT PC I have in my office, but I will not be there until next week.
    He didn't know it was impossible, so he did it. (Jean Cocteau)

Posting Permissions

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