Re : revenir au userform premier après gestion du mot de passe
Voici une vue du VBA du userform1 :
Private Sub OK_Click()
Dim Lign As Byte, Mois As String, i As Integer, ctl As Control, psw As Variant
Dim H1 As Integer, H2 As Integer, titi As Variant, essai As Variant
Mois = Format(MonthView1.Value, "m")
Select Case Mois
Case 1
Range("a34").Select
Case 2
Range("a68").Select
Case 3
Range("a102").Select
Case 4
Range("a136").Select
Case 5
Range("a170").Select
Case 6
Range("a204").Select
Case 7
Range("a238").Select
Case 8
Range("a272").Select
Case 9
Range("a306").Select
Case 10
Range("a340").Select
Case 11
Range("a374").Select
Case 12
Range("a408").Select
End Select
'psw = InputBox("Entrez votre Mot de Passe", "VALIDATION")
'If psw = "titi" Then
'ActiveSheet.Unprotect "titi"
'Else
'MsgBox "Désolé, mot de passe incorrect", , "SECURITE"
'Unload UserForm1
'Exit Sub
'End If
'j'aimerais remplacer l'utilisation de msgbox par un userform
' pour la gestion du mot de passe (possibilité de PasswordChar pour le textbox)
' mais je ne sais pas comment revenir dans le userform1
'une fois que le mot de passe a été géré dans le userform2
UserForm2.Show
H1 = 0
H2 = 0
For i = 1 To 16
If Me.Controls("Checkbox" & i) Then
If H1 = 0 Then H1 = i + 7 'Heure minimum
H2 = i + 8 'Heure maximum
Me.Controls("Checkbox" & i).Value = False
Me.Controls("CheckBox" & i).Locked = True
Me.Controls("CheckBox" & i).Visible = False
ActiveCell.Offset(i - 14, Format(MonthView1.Value, "dd")).Value = "x"
ActiveCell.Offset(i - 14, Format(MonthView1.Value, "dd")).AddComment
ActiveCell.Offset(i - 14, Format(MonthView1.Value, "dd")).Comment.Text Text:=Textbox3.Value
End If
Next i
ActiveSheet.Protect "titi"
Textbox3.Value = ""
End Sub
et la vue du userform2 pour la gestion du mot de passe:
Private Sub OK_Click()
Static TentativePW As Byte
If TextBox1.Value = "titi" Then
Else
TentativePW = TentativePW + 1
If TentativePW > 2 Then
MsgBox "Désolé, mot de passe incorrect", , "SECURITE"
Unload UserForm2
Unload UserForm1
Else
MsgBox "Mot de passe invalide, il vous reste " & 3 - TentativePW & " tentative(s)", vbCritical, "ATTENTION !!"
With Me.TextBox1
.Value = ""
.SetFocus
End With
End If
End If
End Sub
peut-être quelqu'un arrivera-t-il à m'aider aujourd'hui avec les codes
merci beaucoup, Gérard