Microsoft 365 Oups ! Quelque chose ne va pas a mon code vba.

hlawson1

XLDnaute Nouveau
Bonjour a tous,
je me prenomme ronny et j'ai crée une application avec le code VBA

Oups ! Quelque chose ne va pas ne va pas a mon code, je ne sais veritablement lequel.

Mon probleme est que j'ai un message "Le mot de passe doit contenir 6 carrectères au minimum" dans MsgBox qui se repecte apres la verification
la question que me me pose es que j'ai mal place le code ou j'ai oublié un element
bref voici le code :

j'ai veritablement besoin d'une solution


Private Sub Cmd_ajouter_Click()

VB:
Private Sub Cmd_ajouter_Click()

On Error Resume Next

'declarer nos variable
Dim DL As Integer

Sheets("BASE_PARAMETRE").Activate
'If MsgBox("Confirmez-vous l'insertion de ce nouveau contact ?", vbYesNo, "Demande de confirmation d'ajout") = vbYes Then

If Txt_Nom = "" Then
MsgBox "Veuillez saisir le NOM ", vbCritical, "Attention"
Exit Sub
End If

If Txt_Prenom = "" Then
MsgBox "Veuillez saisir le PRENOM(S)", vbCritical, "Attention"
Exit Sub
End If

If Txt_DateNaissance = "" Then
MsgBox "Veuillez saisir LA DATE DE NAISSANCE", vbCritical, "Attention"
Exit Sub
End If

If Me.CboBox = "" Then
MsgBox "Veuillez préciser le SEXE", vbCritical, "Attention"
Exit Sub
End If

If Cb_nationalit = "" Then
MsgBox "veuillez saisir la NATIONALITE", vbCritical, "Attention"
Exit Sub
End If

If Stature = "" Then
MsgBox "veuillez CHOISIR LE STATUR", vbCritical, "Attention"
Exit Sub
End If

If Txt_USER < 8 Then
MsgBox "veuillez SAISIR LE NOM D'UTULISATEUR", vbCritical, "Attention"
Exit Sub
End If


If Me.Passebox1 = "" Then
MsgBox "veuillez saisir le MOT DE PASSE", vbCritical, "Attention"
Exit Sub
End If

If Me.Passebox2 = "" Then
MsgBox "veuillez CONFIRMER LE MOT DE PASSE", vbCritical, "Attention"
Exit Sub
End If


If Cb_nationalit = "" Then
MsgBox "Veuillez préciser L'OBJET DE LA VISITE", vbCritical, "Attention"
Exit Sub
End If


If Txt_Code = "" Then
MsgBox "Veuillez saisir le CODE DU VISITEUR ", vbCritical, "Attention"
Exit Sub
End If


                        If Passbax1.TextLength < 6 Then
                            MsgBox "Le mot de passe doit contenir 6 carrectères au minimum"
                            Passbox1 = ""
                            Passebox2 = ""
                            
                        ElseIf Passbox1 <> passbox2 Then
                            MsgBox "Le mot de passe saisir est différengt!"
                            Passbox1 = ""
                            Passebox2 = ""
                        End If


                        If Me.Txt_Code <> "" Then
                        If Me.Txt_Nom <> "" Then
                        If Me.Txt_Prenom <> "" Then
                        If Me.CboBox <> "" Then
                        If Me.Txt_DateNaissance <> "" Then
                        If Me.Txt_LieuNaissance <> "" Then
                        If Me.Cb_nationalit <> "" Then
                        If Me.Txt_USER <> "" Then
                        If Me.Stature <> "" Then
                        If Me.Passebox2 <> "" Then

                        If Me.Txt_Date <> "" Then
                        If Me.Heure_reel <> "" Then

              
              If MsgBox("voulez-vous ajouter les information?", vbYesNo) = vbYes Then
                
                  'ajouter une nouvelle ligne à notre tableau
                   Sheets("BASE_PARAMETRE").ListObjects(1).ListRows.Add
                   'recherche la dernière ligne
                   DL = Sheets("BASE_PARAMETRE").Range("C506532").End(xlUp).Row
                  
                   'ajouter les informations dans la base de données
                  
                   Sheets("BASE_PARAMETRE").Range("A" & DL) = Sheets("BASE_COMMERCIAL").Range("Y1") '.....................numero Id
                  
                  
                   Sheets("BASE_PARAMETRE").Range("B" & DL) = Me.Txt_Code
                   Sheets("BASE_PARAMETRE").Range("C" & DL) = Me.Txt_USER
                   Sheets("BASE_PARAMETRE").Range("D" & DL) = Me.Passebox2
                  
                   Sheets("BASE_PARAMETRE").Range("P" & DL) = Me.Txt_Nom
                   Sheets("BASE_PARAMETRE").Range("Q" & DL) = Me.Txt_Prenom
                  
                   Sheets("BASE_PARAMETRE").Range("R" & DL) = Me.Txt_DateNaissance
                   Sheets("BASE_PARAMETRE").Range("S" & DL) = Me.Txt_LieuNaissance
                   Sheets("BASE_PARAMETRE").Range("T" & DL) = Me.CboBox
                   Sheets("BASE_PARAMETRE").Range("U" & DL) = Me.Cb_nationalit
                  

                  
                   Sheets("BASE_PARAMETRE").Range("V" & DL) = Me.Stature
                  
                   Sheets("BASE_PARAMETRE").Range("W" & DL) = Me.Txt_Date
                   Sheets("BASE_PARAMETRE").Range("X" & DL) = Me.Heure_reel

                  
                  
                   'Incrementer le numero ID
                    Sheets("BASE_PARAMETRE").Range("Y1") = Sheets("BASE_COMMERCIAL").Range("Y1") + 1
                                                                                                                                        


                        Me.Txt_Code = Empty
                        Me.Txt_Nom = Empty
                        Me.Txt_Prenom = Empty
                        Me.CboBox = Empty
                        Me.Txt_DateNaissance = Empty
                        
                        Me.Txt_LieuNaissance = Empty
                        Me.Cb_nationalit = Empty
                        Me.Txt_USER = Empty
                        Me.Stature = Empty
                        Me.Passebox2 = Empty

                        Me.Txt_Date = Empty
                        Me.Heure_reel = Empty

                    

End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If


End Sub
 

hlawson1

XLDnaute Nouveau
Bizarre! Tu édites un code et tu joins un fichier dont le format est inadapté. Mais bon...

Edit: apparemment ce n'est pas le bon fichier.

Bonne continuation.
Bizarre! Tu édites un code et tu joins un fichier dont le format est inadapté. Mais bon...

Edit: apparemment ce n'est pas le bon fichier.

Bonne continuation.
Tu as raison, j'avais la tete en l'aire, une fois de plus désolé
 

Pièces jointes

  • APPLICA.xlsm
    14 KB · Affichages: 9

Eric C

XLDnaute Barbatruc
Bonsoir le forum
Bonsoir hlawson1, cp4, Philippe

Compliqué tout cela. Par curiosité, j'ai parcouru le code initial ??? Aucun mot de passe n'est défini ?? Comment faire une comparaison ??? De toute façon, il y a :
Passbax1 - Passbox1 & Passebox1 ?????????
Philippe a raison, dans ton fichier, où se trouve le UserForm ???
Ce n'est pas être tête en l'air mais brouillon ce soir.
Bonne soirée à toutes & à tous
@+ Eric c
 

Phil69970

XLDnaute Barbatruc
@hlawson1

Tu mets en début de ton USF

Option Explicit

1649188244176.png


Cela t'obligera à déclarer tes variables et tu verras TOUTES tes fautes de frappes .....;)

....Et tu lances ton USF

Tu vas avoir une dizaine de problème lié tous à l'orthographe de :
Passbax1 - Passbox1 & Passebox1 ?????????
comme l'a vu Eric :)

+ 1 erreur ici lié au nom de la feuille 2 qui n'existe pas o_O mais est-ce la bonne version !!!!! ;)🤣

NouvelID = Application.WorksheetFunction.Max(Feuil2.Range("A:A")) + 1

Tu corriges à chaque fois avec la bonne orthographe !!! et le tour est joué avec la satisfaction d'avoir presque trouvé tout seul ..... :rolleyes:

Et si tu es pressé mais tu n'auras rien appris tu regardes le fichier....

*Merci de ton retour

@Phil69970
 

Pièces jointes

  • Applica V1.xlsm
    28.9 KB · Affichages: 7

hlawson1

XLDnaute Nouveau
Je tenais à vous exprimer mes remerciements les plus sincères pour la qualité du travail que vous avez effectué pour moi. Vous avez ainsi contribué à la réalisation de mon fiché. Votre prestation m'a apporté une très grande satisfaction.

cp4, merci à toi, grace a toi, j'ai appris une leçon de la vie​


Phil69970, un grand merci a toi​

Je suis un debutant dans le developpement vba et lorsque je cherche la solution disons joindre le fiche, je recevrais des injure venant de mon superieur... cela m'a affacté moralement.... c'est pour la raison j'ai veritablement oublié le Userform et mettre le fiche au format.

Infiniment merci a tout les personnes ici present...