+ Reply to Thread
Results 1 to 14 of 14

Tabbing from Cell to ComboBox

  1. #1
    Registered User
    Join Date
    10-19-2007
    Posts
    29

    Tabbing from Cell to ComboBox

    I am trying to create a excel based form (not User Form) which meets some our business accessibility standards (i.e. a user who cannot use a mouse, must be able to complete it using the keyboard).

    I have got around the checkbox issue by creating faux checkboxes and asking the users to enter an X if appropriate. However, part of the information that they need to complete is in the form of a drop-down list (the information is being collected by a hidden datasheet for importing into Access and we need to control the format of the information being provided). I originally implemented this by using data validation on a cell and linking to a named range on a hidden sheet (there are over 100 options to select from). This made it easy for the user to tab to the cell with the data validation in it but, because of the length of the options list, it was a bit unwieldy and users were a bit frustrated by not being able to enter the first couple of letters and for the entry to auto-complete (maybe this is possible in a data validation created list but I couldn't seem to implement it). I have now created a combobox in place of the cell (from the Control Toolbox) and linked this to the name range - so far so good and I have autocomplete working. The trouble now is that I can't get the combobox to get focus without using the mouse to click it.

    After writing "War and Peace", what I wanted to know is if I can do this by VBA? The trouble is that I am a good magpie and can kind of cut and paste code if I can find it but I am shocking when it comes to writing anything from scratch. My instinct tells me that I want to trigger some kind of code when the user tabs out of the cell before the combobox to activate and dropdown the combobox and then to be able to either tab or hit enter in order to give focus to the next cell in the form.

    The sheet and workbook are protected with only the cells requiring completion being unlocked.

    Hope someone can help. TIA
    Nicki

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Nicki,

    This macro works with one Control Toolbox TextBox named "TextBox1" on the worksheet. The macro can be expanded to handle more TextBoxes if you need them. If you have any questions let me know.
    Please Login or Register  to view this content.
    How to Save a Worksheet Event Macro
    1. Copy the macro using CTRL+C keys.
    2. Open your Workbook and Right Click on the Worksheet's Name Tab for the Worksheet the macro will run on.
    3. Left Click on View Code in the pop up menu.
    4. Paste the macro code using CTRL+V
    5. Save the macro in your Workbook using CTRL+S

    Sincerely,
    Leith Ross

  3. #3
    Registered User
    Join Date
    10-19-2007
    Posts
    29
    Thanks for the quick reply Leith but I am not sure this is exactly what I need.

    I have tried the code but doesn't do the trick. I have attached a sample of the workbook. It would open with the first input field already selected and the user would then tab through the fields (including the combobox) using the keyboard

    When the user tabs from the input field 3, the focus will move to the combobox and the cursor would appear in the field ready for text entry.

    TIA
    Nicki
    Attached Files Attached Files
    Last edited by barefaced66; 10-19-2007 at 07:14 PM.

  4. #4
    Registered User
    Join Date
    01-16-2007
    Location
    Near the box
    Posts
    58
    Hi Nicki,

    not checked your sheet yet, but you need tabbed via various controls and even cells on sheets, right ? So I think about it a little bit and some solution could be like that:

    Rewrite the default Excel's TAB handler, add events to controls and finally write tab loops.

    Please Login or Register  to view this content.
    Rewriting default TAB:

    Please Login or Register  to view this content.
    Attached Files Attached Files
    ? ? ? I like the way how Excel can access system API. Really cool ! ? ? ?

  5. #5
    Registered User
    Join Date
    10-19-2007
    Posts
    29
    Bettatronic - thanks I'll look at this tomorrow when the level of red wine decreases and it makes more sense!

  6. #6
    Registered User
    Join Date
    01-16-2007
    Location
    Near the box
    Posts
    58
    The wine definitely away ?

    As I've seen inside your sheet it's needed to hold the default excel's TAB behaviour. So solution via OnKey method is forbidden now.

    So something else. Here we check outgoing cells, in your case it's the celll above the combobox. Once the cell is left we focus the combobox.

    Combobox has some key event too to focus next cell below.

    module1::
    Please Login or Register  to view this content.
    Workbook event::
    Please Login or Register  to view this content.
    ComboBox1 event::
    Please Login or Register  to view this content.
    Have fun !
    Attached Files Attached Files
    Last edited by bettatronic; 10-19-2007 at 09:14 PM.

  7. #7
    Registered User
    Join Date
    10-19-2007
    Posts
    29
    This doesn't seem to do the trick when I incorporate the code into my workbook. Can you implement it on the test file that I posted? I see that it sort of works on the file that you attached.

    Thanks (now with a clearer head)

  8. #8
    Registered User
    Join Date
    01-16-2007
    Location
    Near the box
    Posts
    58
    Hi Nicki,

    of course i can try within your test sheet. But what about the test sheet protection ? Any key ? Or post the sheet once again but with unprotected VB.

  9. #9
    Registered User
    Join Date
    10-19-2007
    Posts
    29
    Bettatronic - sorry, the password is "SkimmedMilk"

    Thanks
    Nicki

  10. #10
    Registered User
    Join Date
    01-16-2007
    Location
    Near the box
    Posts
    58
    Try it Nicki. shift+PageDown to view full list. I hope this help to you.

    Have fun !
    Attached Files Attached Files
    Last edited by bettatronic; 10-20-2007 at 12:20 PM.

  11. #11
    Registered User
    Join Date
    10-19-2007
    Posts
    29

    Thumbs up

    What a star, that is perfect, thank you so much

  12. #12
    Registered User
    Join Date
    10-19-2007
    Posts
    29
    Quote Originally Posted by barefaced66
    What a star, that is perfect, thank you so much
    I think I spoke too soon. When I put that into the full version of the form it still doesn't work. I don't know whether it is a conflict with the other code in the full form, so am attaching an "anonymised" version of it to see whether you can get it work?

    Once again, thanks for your time and effort.
    N

    test.zip

  13. #13
    Registered User
    Join Date
    01-16-2007
    Location
    Near the box
    Posts
    58
    Want to know what was wrong there ?

    The name of component was different. It's ComboBox1 no TextBox1. All procedures had TextBox1 name inside. Also the style of ComboBox1 must be set to 2 (fmStyleDropDownList). And finally the hidden cell under the combo must be unlocked.

    Now I hope it'll work pretty fine for you Nicki.

    Have fun !
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    10-19-2007
    Posts
    29

    Thumbs up

    Quote Originally Posted by bettatronic
    Now I hope it'll work pretty fine for you Nicki.

    Have fun !
    It works brilliantly, thank you so much again for your time

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1