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

    Another key code question

    On my previous post, I needed to turn off the tab key. I did that with the following code:


    ElseIf KeyCode = "9" Then
    KeyCode = 0
    MsgBox "To save this record, only the return key is allowed."
    End If

    That does exactly what I need. My problem now is I need Shift+Tab to allow the user to go to the previous field. How do I code that?

    Thanks in advance!!

  2. #2
    help_me_with_access is offline help_me_with_excel
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    262
    why did you turn it off again? I forget.

    this sounds like a completely un-necessary anamoly to me. what exactly is the problem here? why do you care so much about forward and backward tabbing again???

  3. #3
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398
    I figured it out. Here's my new code:

    ElseIf KeyCode = "9" Then
    If Shift = "1" Then
    Me.GUTS.SetFocus
    Else
    KeyCode = 0
    MsgBox "To save this record, only the return key is allowed."
    End If

  4. #4
    help_me_with_access is offline help_me_with_excel
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    262
    if you figure things out this quickly, as you've shown more than once now, DON'T POST. it's a pretty common courtesy, ya know?

    good luck to ya anyway though...

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,919
    FYI, a KeyCode is an Integer, not a String.
    If KeyCode = 9 Then
    ...instead of
    If KeyCode = "9" Then.
    (RG for short) aka Allan Bunch Previous MS Access MVP - WinXP Pro, Win7 Pro Win10 Pro - acXP, ac07, ac10, ac13
    How to mark the thread as Solved!
    Teaching is not filling a bucket but lighting a fire.
    Borrowed quote..."Docendo discimus"

  6. #6
    help_me_with_access is offline help_me_with_excel
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    262
    Quote Originally Posted by RuralGuy View Post
    FYI, a KeyCode is an Integer, not a String.
    If KeyCode = 9 Then
    ...instead of
    If KeyCode = "9" Then.
    makes ya wonder how many instances in visual basic where this rule doesn't apply, even tough it should be valid in EVERY IDE. but not in VB, probably because it is not properly maintained.

    have a guess Allan? Mine would be anywhere between 0 situations and infinity.

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

Similar Threads

  1. open form code question
    By budchevy in forum Programming
    Replies: 7
    Last Post: 02-22-2012, 08:56 PM
  2. Code cleanup question
    By irish634 in forum Access
    Replies: 3
    Last Post: 02-17-2012, 02:42 PM
  3. Question about some code in a macro
    By AudiA4_20T in forum Programming
    Replies: 2
    Last Post: 07-11-2011, 08:16 AM
  4. Simple code syntax question
    By mseeker22 in forum Programming
    Replies: 1
    Last Post: 07-07-2011, 03:55 AM
  5. Word code in Access - How to modify my current code
    By Alexandre Cote in forum Programming
    Replies: 0
    Last Post: 11-15-2010, 08:26 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 - Senior Forums