Password/User Name Attempt Count

  • Hi All,


    I have built a database which contains some confidential information and because of this have tried to build some code into it that asks for a user name and password at the start.


    I would like to give the user three attempts to enter the correct info before the workbook shuts down however, I am having problems with this code.


    I hope that some kind sole can take pity on me and help me out with this. I have a feeling that it is probably very easy but I must admit that it is confounding me now.


    I know that most Password features are easy to hack/break but as long as I have something in the database I am covered and my boss is happy.


    Thanks for any help


    Numan

  • Re: Password/User Name Attempts Counter


    You need something like


    Post your code and I will add this for you

  • Re: Password/User Name Attempts Counter


    Hi royuk


    Thanks for the help.


    This is the code from my form (FrmTest)



    This is the workbook code


    Code
    Public passwordcount As Integer
    
    
    Private Sub Workbook_Open()
    passwordcount = 0
    
    
    Sheet1.Activate
    FrmTest.Show
    End Sub


    as you can see, if had a go but I am not sure where the varibles go at all.


    Thanks for the help


    Numan

  • Re: Password/User Name Attempts Counter


    Try this, I haven't checked it.

  • Re: Password/User Name Attempts Counter


    Hi royUK


    Thanks for the response but it still doesn't seem to work, although it does allow the user to have multiple goes which it didn't before.


    What I need is something that will allow the user to enter their username and password incorrectly for up to 3 times and then shut down the workbook or excel.


    Thanks


    Numan

  • Re: Password/User Name Attempts Counter


    Hi Numan,


    To avoid closing of the Userform by close button have this lines code as well.


    [vba]
    Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
    If CloseMode = 0 Then Cancel = True
    End Sub
    [/vba]


    HTH

  • Re: Password/User Name Attempts Counter


    Aplogies for the mistake. I didn't have time to write porperly. HHere's a tested example

  • Re: Password/User Name Attempts Counter


    Thanks for all your help guys, it now works like a dream.


    :thanx:


    Really appreciate it.


    Consider this solved


    Numan

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!