Results 1 to 10 of 10
  1. #1
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402

    Key down

    Hi everyone

    I have placed this code on the key down event of a combo box to prevent the ability to enter text but still use the drop down

    if keycode <>9 then


    keycode=0
    end if

    this works really well

    i have hundreds of combo boxes in my application, is it possible to put this code in a module and then call that with the key down event instead? And would there be any advantage to doing this?

    if so how could I do this

    thanks in advance

    steve

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You could probably create one, though I'm not sure I'd bother. I'm curious why you care if they type? I'd just use the limit to list property to make sure they couldn't type something that didn't exist.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402
    Hi pbaldy

    thanks for the reply, I don't really mind if they type, it's just for me a case of personal preference.
    i had limit to list set, but some of my users asked me if I could stop them typing in the combo list by mistake.

    to be honest it's not much code to copy into the keydown event of each combo box so I think I may just do that

    Steve

  4. #4
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    You could set its Tab Stop to no, then they won't inadvertently get into the field without clicking.

  5. #5
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402
    Hi aytee111

    thanks for the reply, good catch I will make sure I set that, I think I have missed a few tbh

    Steve

  6. #6
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    I hope these Comboboxes don't contain many selections! If users can't enter characters...the Auto Expand won't work! With Auto Expand, as you start typing characters into the Combobox, it moves to selections that match what has been typed, and prevents having to scroll down thru however many selections there are to get to the desired one.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  7. #7
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402
    Hi Missinglinq

    luckily the vast majority of the combo boxes only have very few selections, on the ones that have lots im not going to implement this

    thanks for the catch mate

    Steve

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    If you want to use a function, it wouldn't be hard. Your combo code would look like:

    keycode=FunctionName(keycode)

    and the function would do your logic and pass back the appropriate value.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    sdel_nevo is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    Gloucester, UK
    Posts
    402
    Hi Pbaldy

    I'm really sorry for the late reply, i have only just seen this

    that is fantastic many many thanks for the heads up

    that's just what i was after

    Steve

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums