Strike Three your Out. (1 Viewer)

Russ

New member
Local time
Today, 21:39
Joined
Jan 26, 2000
Messages
5
Created a Database and set restrictions for usage.

However I put a Login in page which really is only for me to see when allowed users log in.

Is there any possible way I can set it so that the user has 3 attempts to log in before kicking them out.

At present I have this in AfterUpdate

If Me.UserName = "Russ" Then
Me.ProceedButton.Enabled = True
Else
Me.ProceedButton.Enabled = False
Me.Try=Me.Try + 1
Me.UserName.SetFocus
End If

At present my VBA is pretty limited and hence I do not know how to proceed to get it to register the 3 attempts and close the program.

:confused:
 

Oldsoftboss

AWF VIP
Local time
Tomorrow, 06:39
Joined
Oct 28, 2001
Messages
2,499
Add a bit more,

If my.try <3 then

If Me.UserName = "Russ" Then
Me.ProceedButton.Enabled = True
me.try = 0 'reset the tries
Else
Me.ProceedButton.Enabled = False
Me.Try=Me.Try + 1
Me.UserName.SetFocus

else

POQ

end if
End If
 

Oldsoftboss

AWF VIP
Local time
Tomorrow, 06:39
Joined
Oct 28, 2001
Messages
2,499
Thinking further

Dim Tries as Integer

If Tries <3 then

If Me.UserName = "Russ" Then
Me.ProceedButton.Enabled = True
Tries = 0 'reset the tries
Else
Me.ProceedButton.Enabled = False
Tries= Tries + 1
Me.UserName.SetFocus

else

POQ

end if
End If

This way you dont have to have a field on your form called try.
To Dim adds a bit in the computers memory to store info.

HTH
Dave
 

Graham T

Registered User.
Local time
Today, 21:39
Joined
Mar 14, 2001
Messages
300
Russ

I have used the followingcode attached to the Login button to kick them out if they try more than 3 logins:

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

The final section (the intLogonAttempts) checks the login tries.

HTH

Graham
 

rhounsome

Registered User.
Local time
Today, 21:39
Joined
Jul 16, 2001
Messages
36
Cheers Graham it works great. Took me a bit of time to work out what everything meant but works exactly like I wanted to.

Thanks to all the others for their input.
 

Graham T

Registered User.
Local time
Today, 21:39
Joined
Mar 14, 2001
Messages
300
Russ

Not a problem, however I should not take credit for this one as the code was found on this forum quite a while ago.

Unfortunately I can't remember who posted it.

Graham
 

Oldsoftboss

AWF VIP
Local time
Tomorrow, 06:39
Joined
Oct 28, 2001
Messages
2,499
I quite often copy and paste code into word for future reference. There are many handy tips you will come across, may not be relevant at the time but will save hours of searching in the future.
Dave
 

Users who are viewing this thread

Top Bottom