Results 1 to 7 of 7
  1. #1
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389

    How can i stop all shortcut keys on form


    When I run MS Access form, if I press shortcut keys like control a, control c, control v, control d or control f, then the data of main data table gets messed up.
    Is there any way to prevent the user from using these shortcut keys?
    Thank you.

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    See similar threads at the bottom of this one

  3. #3
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    Quote Originally Posted by cj_london View Post
    see similar threads at the bottom of this one
    where...?
    I not found
    can u provide me its link please...

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    this is a common question and thought a couple of them used methods so you can detect the key, but it would appear not

    So I just googled your question and found numerous links

    https://duckduckgo.com/?q=access+vba...t=opera&ia=web

    the first one looks like it does what you require

    https://stackoverflow.com/questions/...an-access-form

  6. #6
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Office 365
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  7. #7
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    Thank you very much to all of you for solving the problem, if teachers like you are not on this platform, then who knows what would have happened to beginners like us.
    Thank you

    i used this code


    Code:
    Private Sub Form_Open(Cancel As Integer)
    Me.KeyPreview = True
    End Sub 
    
    Private Sub Form_KeyDown(keycode As Integer, shift As Integer)
    sb_disablekeys keycode, shift
    End Sub
    
    Public Sub sb_disablekeys(keycode As Integer, shift As Integer)
        'All keyboard events with CTRL don’t function anymore with the exception of CTRL+C and CTRL+V
     '   ‘All keyboard events with ALT don’t function anymorge
     '   ‘All function keys are disabled
     
        Select Case shift
            Case acCtrlMask   '  ‘CTRL pressed
                Select Case keycode
                    Case 0 To 16, 18 To 66, 68 To 85, 87 To 255
    
                    'All keycodes with the exception of 17 (CTRL), 67 (CTRL+C) and 86 (CTRL+V) are set to 0.
                        keycode = 0
                End Select
            Case acAltMask      'Alt pressed
                        keycode = 0
        End Select
    
        Select Case keycode
            Case vbKeyF1 To vbKeyF16        '        ‘Function key pressed
                keycode = 0
        End Select
    End Sub

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

Similar Threads

  1. Replies: 1
    Last Post: 06-11-2015, 06:15 AM
  2. Replies: 1
    Last Post: 01-06-2015, 06:29 AM
  3. Replies: 5
    Last Post: 03-15-2014, 05:27 PM
  4. New form shortcut?
    By dekhelia in forum Forms
    Replies: 4
    Last Post: 10-15-2013, 10:59 AM
  5. Replies: 2
    Last Post: 11-29-2009, 12:00 PM

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