Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable "copy"

Status
Not open for further replies.

tobymom

Programmer
Aug 18, 2006
36
US
Dear experts,

How can I prevent a user from "copy" the whole datasheet by using "copy and paste"? For example, a user can easily "copy" a whole datasheet then paste it into excel sheet.

Thank you in advance.
 
If you use forms, you can set the controls to Locked an not enabled. Then they shouldn't be able to select the data to copy it. I am 90% sure this should work for a form in datasheet view.
 
lameid,
Thank you for your input. Unfortunately, it didn't work. I'll keep search...
Thanks again!
 
How are ya tobymom . . .

Open the form in design view then
[ol][li]Set the forms [blue]Key Preview[/blue] event to [blue]Yes[/blue].[/li]
[li]In the forms [blue]On Key Down[/blue] event, copy/paste the following line (paste in the event, [red]not the event line![/red]):
Code:
[blue]   If Shift = acCtrlMask And KeyCode = vbKeyC Then KeyCode = 0[/blue]
[/li][/ol]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Dear TheAceMan1,

Thank you! It worked great with Ctrl+C method of copying.

However, do you know how to disable "right click"? I can still right click on the top-left corner then copy the whole Datasheet and paste it into excel.

Thanks again.

 
You can set the "Allow short cut menus" to false in the start up options.
 
tobymom said:
[blue] . . . do you know how to disable "right click"? [purple]I can still right click on the top-left corner then copy the whole Datasheet and paste it into excel.[/purple][/blue]
Its easier to disable the [blue]Cut & Copy[/blue] popup selections. However be aware: [purple]the popup is an access system menu and will be set for all databases you open[/purple]. To keep things in order you need to put them back before you leave the current db. On or off this is easily done.

So ... in a module in the modules window, copy/paste the following routine:
Code:
[blue]Public Sub CutCopyCtl(Show As Boolean)
   Dim CBar As Object
   
   Set CBar = CommandBars("Form Datasheet Row")
   
   CBar.Controls("Cut").Enabled = Show
   CBar.Controls("Copy").Enabled = Show

   Set CBar = Nothing
   
End Sub[/blue]
Call the routine from anywhere to set your preference:
Code:
[blue]   Call CutCopyCtl(True) [green]'enable selections[/green]
   Call CutCopyCtl(False) [green]'disable selections[/green][/blue]
Also ... before I forget, you also need to prevent the keys [blue]CTRL+X[/blue]. So change the previous code I gave you for the keys to the following:
Code:
[blue]   If Shift = acCtrlMask Then
      If KeyCode = vbKeyC Or KeyCode = vbKeyX Then KeyCode = 0
   End If[/blue]
Thats it ... give it a whirl and let me know.

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
TheAceMan1,

I'll give it a try and let you know.
Thank you so much for your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top