Security demo

jonamua1971

Registered User.
Local time
Today, 03:41
Joined
Mar 3, 2007
Messages
97
Any help will be highly apprecited.
i found a security demo databse on this forum and it is excellent but i need help with the codes to put on forms as they load.
1.Admin.acts as the over all adminstrator for the database. Has full controll over all data and objects contained in the database.
2.Manager>Has full access to data but is limited to their section.
3.Supervisor:Has view access to data but is limited to their section.
4.User:Has acccess to select data and is limited to their Office.
5.Guest:Has view control to data only
samples of code
Code:
Private Sub Form_Open(Cancel As Integer)
On Error GoTo Err_Form_Open
    
    If User.AccessID = 1 Then
 'Here list all buttons that should be anabled for Admin only
        Me.cmdAdmin.Enabled = True
    Else
        Me.cmdAdmin.Enabled = False
    End If

    If User.AccessID = >1 Then
 'Here list all buttons that should be enabled for level 2 only
        Me.cmdbutton.Enabled = True
    Else
        Me.cmdbutton.Enabled = False
    End If
    
Exit_Form_Open:
    Exit Sub
Err_Form_Open:
    MsgBox Err.Description
    Me.Visible = True
    Resume Exit_Form_Open
          
End Sub
 
Since you are using section based security you are probably using a selfmade security system based on login (windows-account).

If userrights are cumulative and the user can do anything a guest can plus some user specific stuff, when opening a form you can use that to disable/hide controls.

Code:
Private Sub Form_Open(Cancel As Integer)
On Error GoTo Err_Form_Open
    
 'Here list all buttons that should be anabled for Admin only
        Me.cmdAdmin.Enabled = user.accessid=1
        Me.cmdbutton.Enabled = user.accessid<=2
    
Exit_Form_Open:
    Exit Sub
Err_Form_Open:
    MsgBox Err.Description
    Me.Visible = True
    Resume Exit_Form_Open
          
End Sub
 
thank you very much
 

Users who are viewing this thread

Back
Top Bottom