A possible solution would be to clear the clipboard when you enter a control.
In a module (not form code module) paste this code:
Code:
Public Declare Function CloseClipboard Lib "user32" () As Long
Public Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function EmptyClipboard Lib "user32" () As Long
Example of a control that you want to prevent pasting into:
Code:
Private Sub phonenumber2_GotFocus()
OpenClipboard Me.hwnd
EmptyClipboard
CloseClipboard
End Sub
I can understand someone not wanting users to be able to paste things into a location. One would be a password input. There could be others as well. It will be interesting to see what the OP says.
My solution of clearing the clipboard will always work.
The problem with the autokeys method is that you can still paste into the control with other methods. The autokey method is also an all or nothing method. What it you want to do it only in one single control on one form, and no other place? ou will still need to add more code to block the other ways of pasting.
Good thought, just for FYI (and because I started having a mini-infarction at overlooking this) ... I just did a test in Access'07. It seems that if a control is set to password format (*****) the copy command on the ribbon, right-click menu, and ctrl-c shortcut are auto-disabled - but paste is not.
I can understand someone not wanting users to be able to paste things into a location. One would be a password input. There could be others as well. It will be interesting to see what the OP says.
Why would you care if someone paste into a control that is used for password input?
The few secured applications that I just tried, all let me paste the password, but not copy. Do you have an example of an application that does not allow a password to be pasted? They do limit the attempts you get before they lock the account down.
Not allowing copy makes sense to me, but not paste.