login form

GaryW

New member
Local time
Today, 23:32
Joined
Oct 29, 2002
Messages
8
i have a table of users, each with a user name and password, and a login form set up. i want the user name and password entered on the login form to be compared against those stored in the table. if a match is found the user is allowed to access to the system, if not they are not allowed access.

i would be grateful of any help

Gary
 
I'd suggest that instead of defining your own user/password tables you take a look at Access' inbuilt security features. You can define a set list of users with specific privileges on each table, query or form in the database. You can also define groups to which users belong and apply these privileges to the whole group at a time.
I'd read up before attempting this rather than taking it step by step from the help files - it is possible to lock your database entirely if you lose certain login information (even to yourself). However, the whole process isn't too complex and certainly will make your database more secure.
 
Gary

I have used the following to check users and passwords stored in a table (tblEmployees).

The user chooses their name from a combo box (cbo.Employee) and enters their password into a text box (txtPassword) before clicking on the command button (cmdLogin) -

Code:
Option Compare Database
Private intLogonAttempts As Integer

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 splash screen
        
        DoCmd.Close acForm, "frmLogon", acSaveNo
        DoCmd.OpenForm "frmSplash_Screen"

        Else
        MsgBox "Password Invalid.  Please Try Again", 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
Store: Public lngMyEmpID As Long in a module

Hopefully this should work fine with what you are trying to do.

HTH

Graham
 
where does Store: Public lngMyEmpID As Long in a module go and what is the lngEmpID?

What are the field names that store password and user?
 
I find that restricting users depending on what user has loged into windows is useful because the user is not wasting time going through all these security checks. This is only recommended if you know your users have limited knowlegde of Access

This however is not as secure as if you had done it like "DaveMere" has suggested. for instance a restricted user who may change one table but not any others can just press the shift key to enter the entire database and they will get around the password form by changing the password form into design view and then closing it. you are then at their mercy.
 
Thank you for your opinion but. I still want to know

where does Store: Public lngMyEmpID As Long in a module go and what is the lngEmpID?

What are the field names that store password and user?
 
Use a combination of both (depending if you need to connecto to other mdbs).

User/groups in the work group file to stop people connecting to and changing data in your tables.
(You only need two users tho and two groups in a addition to the standard ones - one for developers and one for users)
Then use a table log on as well to allow users onto your db (as this makes the users keep the db updated rather than you having to keep adding users to the workgroup file - which is a pain in the butt and means you have to support the db more rather than working on enhancements/new dbs).

You can use code to allow forms to be read only or read/write. There is the Access startup options plus shift-entry disable, and a loop to turn off all toolbars (except your own of course...) code to create your own toolbar and you can enable bits as and when users are allowed to see them.

Takes a while to get this set up - but once you've programmed it yourself you can copy into new dbs.

Oh and you'll need a launcher mdb of some sort to connect to the right mdw (workgroup file) and copy the fe from the shared area to the local drive.
 
Thank you but I just want to know.


where does Store: Public lngMyEmpID As Long in a module go
what is the lngEmpID?
What are the field names that store password and user?
 
A Sample Login

Review Sample located HERE


User Name: Ronald Reagan
Password: Ronald



**Disclaimer**

This login does not provided user level security as ACCESS built in security does. (anyway I dont like ACCESS built in security)
 
I can't open it, I get hte unrecognized d.b. format, I'm using 97.
How do you connect the DOA?
could you just email it to me zipped at teiben@contplastics.com, I would greatly appreciate it
 
Sure, my mistake, I have ACCESS XP, let me prepare a version on ACCESS 97... I'll be back
 
not quite sure if it works on 97

User Name: Ronald Reagan
Password: Ronald
 

Attachments

Thank you very much. Glad you uploaded it here, our network strips out file attachments
 

Users who are viewing this thread

Back
Top Bottom