Ajout d'un message box de confirmation

Bonjour,

Je voudrais ajouter un Msgbox à la commande CmdButtonENREGISTRER_Click afin de décider si oui l'enregistrement doit s'exécuter

ou non pour ne pas le faire.

Private Sub CmdButtonENREGISTRER_Click() ' Enregistrer

    If Me.TextBoxInsererMontant = "" Then
        MsgBox "Vous n'avez pas renseigné le montant a Partager", vbInformation, "Saisie manquante"
        Me.TextBoxInsererMontant.SetFocus
        Exit Sub
    End If
    If Me.TextBoxDATE_Enregistree Like "##/##/####" And IsDate(TextBoxDATE_Enregistree.Value) Then
        Worksheets("PARTAGE GLOBAL").Range("G5").Value = CDbl(TextBoxInsererMontant.Value)        ''  << ici
        Worksheets("PARTAGE GLOBAL").Range("G4").Value = CDate(TextBoxDATE_Enregistree.Value)     ''  << ici
    Else

        MsgBox "Attention, saisissez une date de réception en respectant le format JJ/MM/AAAA.", vbExclamation, "Saisie manquante"
        TextBoxDATE_Enregistree.SetFocus
        Exit Sub

        '__________________________________________________________________________
        With ThisWorkbook.Worksheets("PARTAGE GLOBAL").Range("G5")
            .Value = TextBoxInsererMontant.Value
            .NumberFormat = "#,##0"
        End With
    End If
    '__________________________________________________________________________

    CmdButtonFERMER_Click
End Sub

Avec cet exemple:

Sub MsgBoxVariable()

Dim réponse As Integer
réponse = MsgBox("Voulez-vous continuer?", vbQuestion + vbYesNo)

  If réponse = vbYes Then
    MsgBox "Oui"
  Else
    MsgBox "Non"
  End If

End Sub

Cordialement.

Bonjour

A placer avant "If Me.TextBoxDATE_Enregistree Like "##/##/####"..."

dim rep as byte
rep=msgbox("Voulez vous enregistrer cette fiche", vbOKCancel)
if rep<>1 then exit sub
If Me.TextBoxDATE_Enregistree Like "##/##/####" And 

A+ François

Bonsoir fanfan38,

Merci infiniment !

Private Sub CmdButtonENREGISTRER_Click() ' Enregistrer

    If Me.TextBoxInsererMontant = "" Then
        MsgBox "Vous n'avez pas renseigné le montant a Partager", vbInformation, "Saisie manquante"
        Me.TextBoxInsererMontant.SetFocus
        Exit Sub
    End If
    Dim rep As Byte
    rep = MsgBox("Voulez vous enregistrer cette fiche", vbOKCancel)
    If rep <> 1 Then Exit Sub
    If Me.TextBoxDATE_Enregistree Like "##/##/####" And IsDate(TextBoxDATE_Enregistree.Value) Then

        Worksheets("PARTAGE GLOBAL").Range("G5").Value = CDbl(TextBoxInsererMontant.Value)        ''  << ici
        Worksheets("PARTAGE GLOBAL").Range("G4").Value = CDate(TextBoxDATE_Enregistree.Value)     ''  << ici
    Else

        MsgBox "Attention, saisissez une date de réception en respectant le format JJ/MM/AAAA.", vbExclamation, "Saisie manquante"
        TextBoxDATE_Enregistree.SetFocus
        Exit Sub

        '__________________________________________________________________________
        With ThisWorkbook.Worksheets("PARTAGE GLOBAL").Range("G5")
            .Value = TextBoxInsererMontant.Value
            .NumberFormat = "#,##0"
        End With
    End If
    '__________________________________________________________________________

    CmdButtonFERMER_Click
End Sub

ça marche !

Cordialement.

userform 19
Rechercher des sujets similaires à "ajout message box confirmation"