Able to copy data from BE Tables through the FE forms (1 Viewer)

Juolupuki

Registered User.
Local time
Today, 12:59
Joined
Jan 3, 2018
Messages
31
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
 

isladogs

MVP / VIP
Local time
Today, 12:59
Joined
Jan 14, 2017
Messages
18,247
Welcome to AWF

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.
 

Juolupuki

Registered User.
Local time
Today, 12:59
Joined
Jan 3, 2018
Messages
31
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?

Thanks
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 21:59
Joined
Jan 20, 2009
Messages
12,853
You could try to come up with something using the Form's KeyDown Event. It includes a mask for the Control Shift and Alt keys.

There is also KeyUp.

Maybe you could use one of them to unselect the data.
 

isladogs

MVP / VIP
Local time
Today, 12:59
Joined
Jan 14, 2017
Messages
18,247
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

For more info, see the example database in post 18 of this thread:
https://www.access-programmers.co.uk/forums/showthread.php?t=294135&highlight=lock+database

Finally suggest you also lock down the entire database in the Options menu
e.g. prevent use of Access special keys, do not allow full menus etc
 

CJ_London

Super Moderator
Staff member
Local time
Today, 12:59
Joined
Feb 19, 2013
Messages
16,629
Is this what you are looking for?

Code:
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
 

Juolupuki

Registered User.
Local time
Today, 12:59
Joined
Jan 3, 2018
Messages
31
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
For the error see attached please.

Or im wrong??
Thanks
 

Attachments

  • 2.JPG
    2.JPG
    27.9 KB · Views: 41

CJ_London

Super Moderator
Staff member
Local time
Today, 12:59
Joined
Feb 19, 2013
Messages
16,629
using my example

copy to module and change to

Code:
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
 

Juolupuki

Registered User.
Local time
Today, 12:59
Joined
Jan 3, 2018
Messages
31
Thanks to everyone for suggestions was really helpfull ;)

Have been sorted.

I think it can be closed.
 

isladogs

MVP / VIP
Local time
Today, 12:59
Joined
Jan 14, 2017
Messages
18,247
Glad to hear its sorted.
You can't close the thread
Instead please mark the thread as SOLVED in thread tools.
 

Users who are viewing this thread

Top Bottom