1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
' ce code permet à l'accès à un autre userforme si l'utilisateur écrit correctement son identifiant et son mots de passe et chosit sa fonction
Private Sub CommandButton1_Click()
Dim ab As Range ' la cellule qui corrspond au nom cherché d'utlisateur dans la feuille 2de classeur data base
Dim lig As Integer 'la ligne de la cellule cherché(ab)
Dim col As Integer ' la colone de la cellule cherché(ab)
Dim nom as string 'nom de classeur ou se trouve la base de données
' on verifie que l'identifiant et le mots de passe ne sont pas vide
If (TextBox1.Value = " ") Or (TextBox2.Value = "") Then
MsgBox "Please Enter your Username and Password ", vbOKOnly + vbExclamation
Else
' dés que l'utilisateur tape son identifiant et son mots de passe on distingue 3 cas possible s'il a choisi sa fonction comme manager on fait la recherche dans le classeur data base de cette facon
If (OptionButton2.Value = True) Then
If (TextBox1.Text = Workbooks(nom ).Worksheets("Sheet2").Range("C14").Value) And (TextBox2.Text = Workbooks(nom).Worksheets("Sheet2").Range("D14").Value) Then
Me.Hide
UserForm2.Show
Unload Me
Else
MsgBox " Username or Password is incorrect.Please try again", vbOKCancel + vbCritical + vbDefaultButton1, "Erreur"
End If
End If
's'il a choisi sa fonction comme technicien la verification de mots de passe et d'identifiant sera faite de cette facon
If (OptionButton1.Value = True) Then
With Workbooks(nom).Worksheets("Sheet2")
Set ab = .Range("E:R").Find(TextBox1.Text, lookat:=xlWhole)
If ab Is Nothing Then
MsgBox " Username is incorrect.Please try again", vbOKCancel + vbCritical + vbDefaultButton1, "Erreur"
Else
lig = ab.Row
col = ab.Column
If TextBox2.Text = .Cells(lig, col + 1) Then
Me.Hide
UserForm2.Show
Unload Me
Else
MsgBox " Password is incorrect.Please try again", vbOKCancel + vbCritical + vbDefaultButton1, "Erreur"
End If
End If
End With
End If
' si l'utilsateur n'a pas choisi sa fonction alors un msg d'erreur
If (OptionButton1.Value = False) And (OptionButton2.Value = False) Then
MsgBox "Choose your Function", vbOKOnly + vbInformation
End If
End If
End Sub
Private Sub CommandButton2_Click()
Unload Me
End Sub
Private Sub Label2_Click()
End Sub
Private Sub Label3_Click()
End Sub
Private Sub OptionButton1_Click() |
Partager