Results 1 to 7 of 7
  1. #1
    5 Star Lounger AndrewKKWalker's Avatar
    Join Date
    Apr 2001
    Location
    Cambridge, UK
    Posts
    1,020
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Disable Copy with CTRL C (Access 2000 etc or VB)

    I've tried everywhere to get this solution. but no joy.
    Surely some clever person out there knows the answer.

    I need to be able to disable the use of CTRL C to copy.
    This only needs to happen on when certain forms are active so AUTOKEYS is no use.
    I can lose all the menus, it is the CTRL C that foxes me.

    I had a dabble with variations of KeyDown and KeyPress events which I have used before
    but I cannot wrap my head round whether they could stop this or if so how.
    Anyone got any solutions or a direction to a suitable site.

    I need to do this in an Access database, but it might also turn up in a vb app as well.

    Thanks
    Andrew

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disable Copy with CTRL C (Access 2000 etc or VB)

    I don't know for VB.
    For an Access form set the Key PreView property of the form to Yes.
    In the On Key Down event of the form ,use this code :
    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = 67 And Shift = 2 Then
    KeyCode = 0
    End If
    End Sub
    Francois

  3. #3
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disable Copy with CTRL C (Access 2000 etc or VB)

    Reposted from VBA forum when cross-posted thread was locked. And edited, when Francois' post showed me a forgotten command! <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    Hi Andrew

    In the _KeyDown(KeyCode As Integer, Shift As Integer) event procedure, can you use something like:

    If KeyCode = vbKeyC And Shift = vbCtrlMask Then
    MsgBox "Can't copy from here!", vbExclamation : KeyCode = 0

    Alan

  4. #4
    5 Star Lounger AndrewKKWalker's Avatar
    Join Date
    Apr 2001
    Location
    Cambridge, UK
    Posts
    1,020
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Disable Copy with CTRL C (Access 2000 etc or VB)

    Excellent Stuff.

    Worked like a dream.

    I just hadn't got to grips with the functionality of the Shift Parameter.

    Thanks

    Andrew
    Andrew

  5. #5
    5 Star Lounger AndrewKKWalker's Avatar
    Join Date
    Apr 2001
    Location
    Cambridge, UK
    Posts
    1,020
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Disable Copy with CTRL C (Access 2000 etc or VB)

    Thanks.

    only thing, vbCtrlMask is not a valid Constant (at least not in Access 2000)

    However, it works perfectly if

    Const vbCtrlMask = 2 is placed in the code.

    Thanks
    Andrew

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Disable Copy with CTRL C (Access 2000 etc or VB)

    Try using acCtrlMask instead of vbCtrlMask. acCtrlMask is a built-in Access constant.

  7. #7
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disable Copy with CTRL C (Access 2000 etc or VB)

    Thanks Hans. I'd forgotten about Access-specific constants and similar.

    Alan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •