Disabling Copy and paste function

Phonik

Registered User.
Local time
Today, 17:17
Joined
Sep 22, 2006
Messages
111
Hi there,

I am a database designer for a UK Insurance company and have recently needed to rebuild our complaints database. One of the problems with the previous database was that staff were copying text from an application designed by Pacific Solutions (PACSOL). When the data was pasted into our Complaints database, it was causing some serious issues that made the database crash. This had started to affect people's confidence in our ability through no fault of our own. We then found out that this was due to the character set of PACSOL not being supported by access.
What we would like to do in the new database is prevent users from copying and pasting text into the system. Perhaps by displaying an error message when they press CTRL+V or do edit - paste.

Does anyone know how this can be done?

Thanks

Gareth
 
I don't think there is a way to trap within access. Would possibly have to be done at the Windows level, which would affect everything (not just access).
The only option I can think of would be to catch it in the OnChange or BeforeUpdate Event of the control.
 
Actually, you can trap this on the on KeyUp event for each control. Just be sure to set the KeyPreview to Yes as well. You will probably have to disable the right click as well and have to modify the allowed menu so that the paste button is not there.
 
Ricky Hicks gets the credit for this one...

As mentioned above, you have to set the "forms" Key Preview property to YES and put this code in the forms KeyDown event...

Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

    Dim intCtrlDown As Integer
    intCtrlDown = (Shift And acCtrlMask) > 0
     
    If KeyCode = vbKeyV Then
      If intCtrlDown Then
        MsgBox "You Pressed Ctl + V"
        KeyCode = 0
      End If
    End If
 
    If KeyCode = vbKeyC Then
      If intCtrlDown Then
        MsgBox "You Pressed Ctl + C"
        KeyCode = 0
      End If
    End If
 
End Sub

Not sure why but this old code I have used for trapping other keys will not work for the Ctrl key [using Access 2003]...
Code:
Private Sub Form_KeyPress(KeyAscii As Integer)

    If KeyAscii = vbKeyControl Then
        KeyAscii = 0
        Beep
        MsgBox "You can not use the Ctrl key.", vbInformation, "Invalid Key Stroke"
    Else
        'do nothing since they did not use the Ctrl key
    End If

End Sub
 
Thanks so much for your help! It works like a charm! Now we can catch the little blighters that persist on pasting when told not to!

Nice one!
 
OK that code works great to stop the control buttons. Is there any way to stop right click and copy, then right click and paste?
 
Is there any way to disable right clicks for just the one form?
 
Yes, create a shortcut menu without any items on it and assign it to that form (see my link for how).
 
Look at you with your own site there Bob. Thank you I will look it up.
 
Found the article I needed and book-marked your page. I am sure I will use it many, many, many times! Thank you so much!
 
GladWeCouldHelp.png
 

Users who are viewing this thread

Back
Top Bottom