How to set up log inform with different rights

phatus

Registered User.
Local time
Today, 10:52
Joined
Nov 10, 2010
Messages
100
hi i have my log in form with 2 user, my problem is they are both admin user...
what i want is user1 admin user, can edit fields in the form, and user2 cannot edit in the form...

here is the code behind the login button in my log in form:
Code:
Private Sub cmdLogin_Click()

'Check to see if data is entered into the UserName combo box

    If IsNull(Me.cboEmployee) Or Me.cboEmployee = "" Then
            MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
            Me.cboEmployee.SetFocus
        Exit Sub
    End If

'Check to see if data is entered into the password box

    If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
            MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
            Me.txtPassword.SetFocus
        Exit Sub
    End If

'Check value of password in tblEmployees to see if this matches value chosen in combo box

    If Me.txtPassword.Value = DLookup("strEmpPassword", "tblEmployees", "[lngEmpID]=" & Me.cboEmployee.Value) Then

        lngMyEmpID = Me.cboEmployee.Value

'Close logon form and open master
        
        DoCmd.Close acForm, "master", acSaveNo
        DoCmd.OpenForm "master"

        Else
        MsgBox "Password Invalid.  Please Try Again or Ask for Assistance - Arky", vbOKOnly, "Invalid Entry!"
        Me.txtPassword.SetFocus
    End If
    
'If User Enters incorrect password 3 times database will shutdown
    
    intLogonAttempts = intLogonAttempts + 1
    If intLogonAttempts > 3 Then
        MsgBox "You do not have access to this database.  Please contact your system administrator.", vbCritical, "Restricted Access!"
        Application.Quit
    End If
    
End Sub

thank you
 
I spotted several issues with your flow logic.

Example:
If the user gets the password correct on the third (3) or forth (4) attempt (depends on if you initialize intLogonAttempts to 0 or 1 someplace else) the database will still shut down on them when it should not.

You might want to check out this example: Boiler Plate Database
 
actually it will shutdown ^ ^... ill check the link you give me sir...

do you have more simplier sample of the dabatase?
 
Last edited:
Attached is a sample database that I placed on another forum.

It has three access levels. Open the form frm_main, the user ids and passwords are displayed for each level. There is no restrictions in the number of times that an user can attempt to login.

Module mod_display_menu has the code to validate the user_id, password and access levels.
 

Attachments

@Poppa Smurf

i seen your sample data base it too much complicated i have a very limited knowledge in VBA

can you make a sample of just 2 user

here is the rights:
user1=cant edit,add,delete in the form he can only scroll and can view the reports
user2=can edit , add, delete in the form and can view the report..

if you log-in as user1 automatically all fields in the form will be locked
and if you log-in as user to automatically all fields in the form will be unlock

thats all i need sir...

thank you
 
We are here to assist people with problems they are experiencing, not writing their building applications for them.
 
@DCrake
sir i would like to request a sample my knowledge in VB is very low and i have no background in programming... my batabase is already finish.

thank you
 
@Poppa Smurf

i seen your sample data base it too much complicated i have a very limited knowledge in VBA

can you make a sample of just 2 user

here is the rights:
user1=cant edit,add,delete in the form he can only scroll and can view the reports
user2=can edit , add, delete in the form and can view the report..

if you log-in as user1 automatically all fields in the form will be locked
and if you log-in as user to automatically all fields in the form will be unlock

thats all i need sir...

thank you

You really are asking a for a lot of work for free.

When implement a security model like you want, you will probably have to have to modify every form and report.

You have been given several examples you can use. Even if some took the time required to create an example like you have described, it still probably would not just plug into your database.

As I statement in the link I gave you, implementing a security model if not easy. The difficultly level level does not depended on the number of users but the level of security required.
 
Last edited:
ok sir i understand im studying now the sample's that was posted here...

thanks...
 
sir i would like to request a sample my knowledge in VB is very low and i have no background in programming... my batabase is already finish.

Why wait till the end to implement security? this should have been done right from the start.
 
I agree. In my example database after working out the access levels and menu items I then created my login screen then created the forms etc. As stated in previous posts leaving the login and access levels until the database is finished means that you will have to change forms names etc.
 
Adding security at the end can really be a lot of work. It may require some, or possibly a lot changes, to the design of the existing forms and reports if implement security later was not considered in the original design. Unfortunately you would only know what things to consider if you have successfully implemented security in the past.
 

Users who are viewing this thread

Back
Top Bottom