Hello,
Not sure if I'm in the right forum, but I'm looking for help.
Recently find out that in the front End on any form I can select and copy, delete the data in the back end tables.
That's not what I have expected from access
The BE and FE is separated from each other and FE has a login function for each user.
Is there a particular code to lock this behaviour or is this what suppose to do?
Appreciate for any answers.
Thanks
That's what it is supposed to do.
Having said that users should NEVER be working with tables directly.
Hide the navigation pane to prevent access to the.
Users should be using forms to view data.
If you don't want them to edit the data, lock the form.
But of course, make an exception for admin users or the equivalent.
Thats how is set up the users not working or have any access to the tables. The forms are set to add new or edit existing records with no visibility to any other menus, all acces to default menu are blocked with Pop Up, Modal form set up.
Maybe I wasnt clear what is actually happening.
When is form open i can select the record with the keyboard keys CTRL+A and have a copy (with the keyboard CTRL+C) of all records or even delete them all from the table. I have managed to find to turn off with "Allow Deletions" set to NO, seems now not able to delete, but still can copy records to memory and paste in other documents.
Is this can be turned off too?
First of all it is impossible to make any Access database 100% secure against users with high level knowledge. However, there are various things you can do depending on how far you want to lock down your form
1. As well as setting Allow Deletions = No, also set Allow Additions, Allow Edits and allow filters to NO
2. Set Shortcut Menu = NO to prevent right click context menu
3. Lock entire form : Locked = YES (not available in all form types
4. As mentioned by Galaxiom, you can prevent selected key entries from working using Form KeyDown event. For example:
Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
On Error GoTo Err_Handler
'Used to disable selected individual input key values
Select Case Shift
Case acCtrlMask
If KeyCode = vbKeyV Then
MsgBox "Sorry - pasting text is not allowed on this form", vbCritical, "ERROR"
KeyCode = 0
End If
If KeyCode = vbKeyC Then
' MsgBox "Sorry - copying text is not allowed on this form", vbCritical, "ERROR"
KeyCode = 0
End If
If KeyCode = vbKeyA Then
' MsgBox "Sorry - selecting all text is not allowed on this form", vbCritical, "ERROR"
KeyCode = 0
End If
End Select
Exit_Handler:
Exit Sub
Err_Handler:
MsgBox "Error " & Err.Number & " in Form_KeyDown procedure : " & Err.Description
Resume Exit_Handler
End Sub
NOTE:
a) For this to work you MUST also set Key Preview = YES
b) This does NOT prevent all keyboard combinations such as Alt+Tab, Ctrl+Alt+Del, Ctrl+Esc, Win+E
Doing that requires editing the registry
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If (Shift = 2) And (KeyCode = Asc("C") Or KeyCode = Asc("c")) Then
KeyCode = 0
MsgBox "Copying is not permitted"
End If
End Sub
beaten to it by Colin with a more comprehensive answer
Thanks for reponds. Seems i have found in same time similar solution what you sugesting, and i have code too. Quickly tryed, it works!
Just cant manage to get make run from module, i would rather to call function not to copy same code in every form :/. If in near future will be need to add some extra in the code i will be need to check all forms again.
Let say On Key Down event call function:
Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Call MyFunction
End Sub
Function checkKeycode(KeyCode As Integer, Shift As Integer) as integer
If (Shift = 2) And (KeyCode = Asc("C") Or KeyCode = Asc("c")) Then
checkKeycode= 0
MsgBox "Copying is not permitted"
else
checkKeycode=keycode
End If
End Sub
and to call
Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
keycode=checkKeycode(KeyCode, Shift)
end sub
another option that should work is
Code:
Sub checkKeycode(KeyCode As Integer, Shift As Integer)
If (Shift = 2) And (KeyCode = Asc("C") Or KeyCode = Asc("c")) Then
Keycode= 0
MsgBox "Copying is not permitted"
end if
End Sub
and to call
Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
checkKeycode KeyCode, Shift
end sub