how to disable control + X in Access 2010 Forms

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rahul2310
    New Member
    • Oct 2013
    • 62

    #1

    how to disable control + X in Access 2010 Forms

    I have a form bound to table.When i open the form and press control + A it jumps to first record, that is not the problem but when i press control + x it deletes the record from table how do i stop that
    i am trying code below but its not working
    Code:
            Case vbKeyControl + X
                MsgBox "CAN NOT DELETE"
                KeyCode = 0
    The code is on key down event of form
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    There are ways to bypass a key trap.
    Instead, set the form to not allow record deletions:
    Open form in design view
    Open the form's property sheet
    Select the data tab
    Set property [Allow Deletions] = No

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32669

      #3
      If it's simply Ctrl+X that you want to stop, then your code won't work. It is not correct. Unfortunately you haven't included most of the important code so we can't explain why, or what to change to get it to work. When done properly it can work.

      On the other hand, if it's all deleting you want to stop, then the alternative approaches are far more sensible, as the code for Ctrl+X, even when working correctly, will only block the delete when requested by Ctrl+X (and there are many other ways to get a record to be deleted).

      Comment

      • rahul2310
        New Member
        • Oct 2013
        • 62

        #4
        I used AutoKeys Macro
        If someone needs help then i think i should explain
        Create macro name of macro should be AutoKeys (case sensitive it is)
        then submacro and submacro name should be key which you want to disable
        Which is ^X means control + X

        Thanks Neopa and z for ur replys
        regards

        Comment

        • zmbd
          Recognized Expert Moderator Expert
          • Mar 2012
          • 5501

          #5
          As I mentioned in #2, there are ways around even the AutoKeys macro. Even if the user doesn't do one of these workarounds, the AutoKeys has the disadvantage if being global.
          IMHO, #2 is the better method and Neopa's comments are still valid.

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32669

            #6
            I agree strongly. Using an AutoKeys macro for this purpose is inadequate in many ways. It is also much more complicated than necessary. This isn't even a choice - The way to do it should be to set Allow Deletions to No.

            Comment

            Working...