Results 1 to 14 of 14
  1. #1
    5 Star Lounger kmurdock's Avatar
    Join Date
    Feb 2003
    Location
    Pacific Grove, California, USA
    Posts
    716
    Thanks
    10
    Thanked 34 Times in 28 Posts

    Word VBA UserForm behavior (Office 2003 SP3)

    Hi all,

    I have a userform with two list boxes. If someone tabs into the first listbox and uses the arrow key to move down through the items in the list, their cursor will eventually move to the second list box. Since the contents of the second list depend on a selection in the first, this will raise an error message because nothing was selected.

    Is there a way to stop the cursor from moving through the controls on a UserForm using the up and down arrow keys? Or at least a way to stop it from escaping the first list box?

    Thanks!! <img src=/S/bananas.gif border=0 alt=bananas width=33 height=35>
    Kim

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Word VBA UserForm behavior (Office 2003 SP3)

    I cannot reproduce this behavior. When I use the down arrow key to move through the items of a list box, it stops when I've reached the last item. It's similar for the up arrow key: it stops when I've reached the first item in the list box. The focus doesn't move to the next or previous control. I don't see any property that would change this behavior...

  3. #3
    5 Star Lounger kmurdock's Avatar
    Join Date
    Feb 2003
    Location
    Pacific Grove, California, USA
    Posts
    716
    Thanks
    10
    Thanked 34 Times in 28 Posts

    Re: Word VBA UserForm behavior (Office 2003 SP3)

    Yeesh!

    I misspoke (mis-wrote). I did NOT mean list box, I meant *combo* box. When a person uses the down arrow to move through the list in a combo box, they pop into the next combo box.

    Is this just something I have to tell folks not to do? I suppose I could capture the error that's thrown upon entering the second combo box (380) and fling them back to the top of the first box...

    BTW, thank you Hans for the very swift response!

    Kim

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Word VBA UserForm behavior (Office 2003 SP3)

    I can't reproduce the problem with combo boxes either, unless I do the following:
    1) Set the AutoTab property to True
    2) Set the MaxLength property to a number greater than 0.
    3) Using the arrow key, I "hit" an item of MaxLength characters (not necessarily the last item).
    The focus then moves to the next control in the tab order.

  5. #5
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Word VBA UserForm behavior (Office 2003 SP3)

    I can reproduce the behaviour with all properties set to their defaults. Can't figure out how to stop it yet though!
    Regards,
    Rory

    Microsoft MVP - Excel

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Word VBA UserForm behavior (Office 2003 SP3)

    Hmm - I'm using Office XP at the moment. I'll have to test it in Office 2003 at work tomorrow...

  7. #7
    5 Star Lounger kmurdock's Avatar
    Join Date
    Feb 2003
    Location
    Pacific Grove, California, USA
    Posts
    716
    Thanks
    10
    Thanked 34 Times in 28 Posts

    Re: Word VBA UserForm behavior (Office 2003 SP3)

    Hans,

    Here's a document with an example of what I'm talking about. In my installation of Word, this shows the behavior I described. I haven't changed any of the defaults for the dialogs.

    One thing to look at, I suppose, is the references. It would be interesting to see if you have / don't have any of mine.

    Thanks!
    Kim
    Attached Files Attached Files

  8. #8
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Word VBA UserForm behavior (Office 2003 SP3)

    I'm testing on 2003 SP3. Autotab has no effect either way and sadly nor does any other property I've tried. <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15> Just double-checked and the same behaviour occurs in Excel (not really surprising).
    Regards,
    Rory

    Microsoft MVP - Excel

  9. #9
    5 Star Lounger kmurdock's Avatar
    Join Date
    Feb 2003
    Location
    Pacific Grove, California, USA
    Posts
    716
    Thanks
    10
    Thanked 34 Times in 28 Posts

    Re: Word VBA UserForm behavior (Office 2003 SP3)

    I no longer have Word XP installed anywhere so I can't test, but I don't recall this working any differently (for me) in that version.

    Thanks,
    Kim

  10. #10
    5 Star Lounger kmurdock's Avatar
    Join Date
    Feb 2003
    Location
    Pacific Grove, California, USA
    Posts
    716
    Thanks
    10
    Thanked 34 Times in 28 Posts

    Re: Word VBA UserForm behavior (Office 2003 SP3)

    Well, heck.

    I've seen this behavior before, just never had a problem with it. In this particular case, I want to set the list of items in the second combo box based on the selection in the first and then display the first of these items in the second combo box.

    If nothing else, I'd like to see if I can capture... something about the arrow moving through the first list. The Exit event, maybe... What I'd really like to do it move them back to the top of the first list instead of letting them move to the next control. I have a fixed number of items in the first list... Just not sure how to do this.

    Thanks!
    Kim

  11. #11
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Word VBA UserForm behavior (Office 2003 SP3)

    OK, I see what's happening.

    Apparently, when you use the down arrow and reach the last item, the focus goes to the first control below the combo box - not necessarily the next control in the tab order.
    My test userform had only two combo boxes and I had placed the second combo box to the right of the first one. So there was no control below the first combo box to move to...

    Unfortunately, I don't see any way to prevent the focus from shifting to the control below a combo box. <img src=/S/sad.gif border=0 alt=sad width=15 height=15>

  12. #12
    5 Star Lounger kmurdock's Avatar
    Join Date
    Feb 2003
    Location
    Pacific Grove, California, USA
    Posts
    716
    Thanks
    10
    Thanked 34 Times in 28 Posts

    Re: Word VBA UserForm behavior (Office 2003 SP3)

    Well, I think I may have a workaround.

    I've edited the form in my little example. I added a blank line at the bottom of the list -- it won't be all that noticeable to someone who uses the drop-down arrow. When you get to the blank line using the down arrow, it immeidately redirects you and displays the first item in the list.

    Can anyone see a problem with this approach?

    Thanks!
    Kim
    Attached Files Attached Files

  13. #13
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Word VBA UserForm behavior (Office 2003 SP3)

    That appears to work well, whether you use the keyboard or the mouse.

  14. #14
    5 Star Lounger kmurdock's Avatar
    Join Date
    Feb 2003
    Location
    Pacific Grove, California, USA
    Posts
    716
    Thanks
    10
    Thanked 34 Times in 28 Posts

    Re: Word VBA UserForm behavior (Office 2003 SP3)

    I'm going with it, then.

    Thanks for your help, Hans! And thanks also to Rory who reassured me that I actually wasn't <img src=/S/bananas.gif border=0 alt=bananas width=33 height=35> !

    Best, Kim

Posting Permissions

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