Results 1 to 10 of 10
  1. #1
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398

    proper usage of keycode

    I have the requirement that in order to save the record, the used needs to press enter. Using the keycode I can determine if the user presses enter or some other key. If they press some other key, how do I stop all code within this text box from executing and return the focus to this text box? Thanks in advance!!

  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,641
    I'm not clear on the goal, but you can negate the input by setting the key variable to 0.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398
    I tried that, and the result it didn't seem to work. The customer wants the employee to only press enter to save the record. I'll try it again.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Post the code if you don't get it working.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398
    Here's what the customer would like, after the user has entered data, to save the record and advance to the next record, the user can only press enter. Within the properties of the text field their are events in the after update, on got focus, on lost focus. I've enter keycode command in the key down event.

    In my testing, I've entered the following code within the key down event:
    if keycode <> "13" then
    msgbox "You are required to press the enter key"
    end if

    But then the code goes to the after update event

    What do you think?

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    I'm not on a computer right now but I think you want the key press event. And set the variable to 0.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398
    What do you mean by set the variable to 0?

  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,641
    Keyascii = 0
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398
    Thanks!! I think that will do it

  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,641
    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.

Similar Threads

  1. .value usage...
    By Fish218 in forum Forms
    Replies: 2
    Last Post: 03-15-2012, 02:26 PM
  2. CPU Usage
    By worldwidewall in forum Access
    Replies: 9
    Last Post: 02-20-2012, 02:31 PM
  3. Dictionary usage
    By Mclaren in forum Access
    Replies: 1
    Last Post: 11-29-2011, 12:52 PM
  4. Form Usage
    By crowegreg in forum Forms
    Replies: 7
    Last Post: 08-01-2011, 06:16 AM
  5. Keyboard not returning correct keycode
    By Toots in forum Programming
    Replies: 1
    Last Post: 04-14-2011, 10:31 AM

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