Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

les If, End if, Else et autres

1 réponse
Avatar
jfd
Bonjour
Je galère sur un bout de code pour mot de passe :
Celui ci est impec


Dim Rep
Dim stDocName As String
If Me.Txt_MotDePasse = Decrypt(DLookup("MotDepasse", "AARCPMName")) Then
Psw = True
DoCmd.OpenForm "Start"
DoCmd.Close acForm, "Connexion"
Else
Psw = False
Rep = MsgBox("Mot de passe incorrect. (Lecture seule disponible après
activation.)// Incorrect password. (Read-only available after
activation.)", vbExclamation + vbRetryCancel, "E R R E U R")
If Rep = 2 Then 'Cancel
DoCmd.Close acForm, "Connexion"
Else
Me!Txt_MotDePasse = ""
Me!Txt_MotDePasse.SetFocus
End If
DoCmd.SetWarnings True
End If
End If

End Sub
Celui-ci marche très bien, mais quand j’ajoute :(accès à d’autres forms en
lecture uniquement je n’arrive plus à obtenir mon message si password est
faux et je plante)
Else

If (Me.Txt_MotDePasse = (DLookup("Lecture", "Lect"))) Then

If Not Me!AAA = "" Or Not IsNull(Me!AAA) Then

Psw = True
DoCmd.OpenForm "StartLect"
DoCmd.Close acForm, "Connexion"
qui peut m’aider avec les If, End if, Else et autres
merci par avance
jfd

1 réponse

Avatar
Michel_D
"jfd" a écrit dans le message de news:
Bonjour
Je galère sur un bout de code pour mot de passe :
Celui ci est impec


Dim Rep
Dim stDocName As String
If Me.Txt_MotDePasse = Decrypt(DLookup("MotDepasse", "AARCPMName")) Then
Psw = True
DoCmd.OpenForm "Start"
DoCmd.Close acForm, "Connexion"
Else
Psw = False
Rep = MsgBox("Mot de passe incorrect. (Lecture seule disponible après
activation.)// Incorrect password. (Read-only available after
activation.)", vbExclamation + vbRetryCancel, "E R R E U R")
If Rep = 2 Then 'Cancel
DoCmd.Close acForm, "Connexion"
Else
Me!Txt_MotDePasse = ""
Me!Txt_MotDePasse.SetFocus
End If
DoCmd.SetWarnings True
End If
End If

End Sub
Celui-ci marche très bien, mais quand j’ajoute :(accès à d’autres forms en
lecture uniquement je n’arrive plus à obtenir mon message si password est
faux et je plante)
Else

If (Me.Txt_MotDePasse = (DLookup("Lecture", "Lect"))) Then

If Not Me!AAA = "" Or Not IsNull(Me!AAA) Then

Psw = True
DoCmd.OpenForm "StartLect"
DoCmd.Close acForm, "Connexion"
qui peut m’aider avec les If, End if, Else et autres
merci par avance
jfd


Comme cela par exemple.

If (Me.Txt_MotDePasse = (DLookup("Lecture", "Lect"))) Then

If Not Me!AAA = "" Or Not IsNull(Me!AAA) Then


Psw = True
DoCmd.OpenForm "Start"
DoCmd.Close acForm, "Connexion"

End If

Else
Psw = False
Rep = MsgBox("Mot de passe incorrect. (Lecture seule disponible après activation.)// Incorrect password. (Read-only available
after activation.)", vbExclamation + vbRetryCancel, "E R R E U R")
If Rep = 2 Then 'Cancel
DoCmd.Close acForm, "Connexion"
Else
Me!Txt_MotDePasse = ""
Me!Txt_MotDePasse.SetFocus
End If
DoCmd.SetWarnings True
End If