I have a problem.Actually I want to set a counter that allow the user to enter the valid password for 3 times.. if the password fail after 3 times attempt, the form 1 show.How to do that?


Code:
Set adoConn = New ADODB.Connection
    Set adoRS = New ADODB.Recordset

    Dim cs As String
        cs = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\AdminPassword.mdb" & ";Persist Security Info=False;"

    adoConn.ConnectionString = cs
    adoConn.Open

If Text2.Text = "" Then

        MsgBox "Sila masukkan Kata laluan Anda", vbCritical, "Kata laluan"
      '  MsgBox "Sila masukkan Kata laluan Anda"
        Text2.Text = ""
        Text2.SetFocus
    Else
    
     usrnm = Text2.Text
     adoRS.Open "SELECT * FROM pass WHERE password='" & usrnm & "';", adoConn, adOpenStatic, adLockOptimistic
        
   
        
     If adoRS.Fields("Password").Value = Text2.Text Then
        pass = True
        'if password valid, success
        MsgBox "Anda Berjaya memasuki ruang admin" & vbCrLf & "Logged in. Username: " & usrnm & " !", vbInformation, "Selamat datang"
        Form2.Show
        Unload Me
    Else
    'if password invalid,message box ask to insert invalid password
         MsgBox "Kata laluang tidah sah. Ruang ini hanya untuk admin", vbCritical, "WARNING"
         'Exit Sub
         Unload Me
         Form1.Show
    

        Exit Sub
    End If
 End If
End Sub