login and user access

bigmac

Registered User.
Local time
Today, 13:45
Joined
Oct 5, 2008
Messages
302
hi all, I have looked at the demos for login in and user access but I need help in understanding them and how the work.
I have a data base that I want to set a login and user access to but I do not understand the samples you have can someone explain how they work to me please.:confused:
 
Which samples are you talking about?
If you have a specific question someone will help you.
 
Hi BigMac,

I recall these topics (only due to me posting in them)

My Example

Another topic

I am not sure if they answer your query, but if not let me know and I will explain the concept I used. i am sure it came from one of the example databases on these very forums anyway.
 
there are a few aspects to this

1. technically logging in. this needs a table of permitted users and associated passwords. the dbs needs a form to initially capture the users details, and test them against the permits table. relatively trivial to implement

2. there is then vertical access, if you will.
certain forms and reports can be restricted to certain users. the easiest way is to test the users login credentials in the open event, and refuse to open, if the user is not permitted to use the form/report.

the only tricky bit is that each time you add a user you need to set all his permissions.

SO - one way round this is to have groups. a user belongs to a group or groups. the permissions are then examined at the group level to determine access. all you then need is way of adding a new user to the relevant groups. much easier to administer.

3. finally horizontal access, if you will. much more trouble.
various users have access to a given form, but need to see different data depending on who they are. you are only going to be able to do this by maybe modifying the source query to determine which rows should be included/excluded, depending on the user. you may be able to do it with a filter of some sort. either way, it's a lot harder than just completely blocking the form.
 
Hi McSwifty, I have used this method to create a login form very similar http://www.databasedev.co.uk/login.html but do you know if there is a way to stop the same user logging in twice? I have had issue of passwords being shared meaning two users are accessing with the same user and password.

I wanted to add some sort of code to flag if a user is already logged in to prevent this. Is this possible?

Any help would be appreciated.
thanks
Janeyg
 
Hi Janeyg,

I recommend using a 'flag' like a checkbox field in your user table and making sure that is changed to TRUE when the user logs in successfully, on the concurrent attempt you need to check for this being false else fail the login attempt with a message stating the user is already logged in.
 
Thanks McSwifty, I will have a look into how to put this together. :)
 
Hi McSwifty

I am really struggling with this one. I put together some code that I thought would work. Here is the original code which works without the checkbox and 'logged in' text field.
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 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

I then added to the table a checkbox and text field. Here is the code I added, which is a small addition:-

Code:
    Me.LoggedIn = True
    Me.Login = "User Logged In"
    Else
    Me.LoggedIn = False
    Me.Login = "Not Logged In"
End If
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
 
 
    Me.LoggedIn = True
    Me.Login = "User Logged In"
    Else
    Me.LoggedIn = False
    Me.Login = "Not Logged In"
End If
 
'Close logon form and open splash screen
 
        DoCmd.Close acForm, "frmLogon", acSaveNo
        DoCmd.OpenForm "frmSplash_Screen"
 
 
'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

I also added on exit a code to uncheck the box and add the 'not logged in ' text. This works fine.

The problem is that when I log on, it only registers (ticks and adds text) to one user regardless of the name/password I choose. I just can't figure why or make the connection to this?

Any help would be much appreciated.
thanks
janeyg
 
Last edited:

Users who are viewing this thread

Back
Top Bottom