Private Sub CommandButton1_Click()
Dim Date_entree As Date
Dim Date_sortie As Date
Dim Derligne As Long
'Contrôle date d'entrée
If Me.TextBox1.Value <> "" Then
If Not IsDate(Me.TextBox1.Value) Then
MsgBox "La date d'entrée saisie n'est pas un date valide !"
Me.TextBox1.SetFocus
Exit Sub
Else
Date_entree = CDate(Me.TextBox1.Value)
End If
End If
'Contrôle date de sortie
If Me.TextBox6.Value <> "" Then
If Not IsDate(Me.TextBox6.Value) Then
MsgBox "La date de sortie saisie n'est pas un date valide !"
Me.TextBox6.SetFocus
Exit Sub
Else
Date_sortie = CDate(Me.TextBox6.Value)
End If
End If
'Inhibe l'affichage
Application.ScreenUpdating = False
'Déprotection
Call ToutDeproteger
'Ajouter un nouvel article
If MsgBox("Confirmer la saisie", vbYesNo, "confirmation") = vbYes Then
With ThisWorkbook.Sheets("Saisie")
.Select
Derligne = .Range("F" & Rows.Count).End(xlUp).Row + 1
.Cells(Derligne, 4) = IIf(Date_entree = 0, "", Format(Date_entree, "dd/mm/yyyy"))
.Cells(Derligne, 5) = IIf(Date_sortie = 0, "", Format(Date_sortie, "dd/mm/yyyy"))
.Cells(Derligne, 6) = ComboBox1.Value
.Cells(Derligne, 7) = ComboBox2.Value
.Cells(Derligne, 8) = ComboBox3.Value
.Cells(Derligne, 9) = TextBox2.Value
.Cells(Derligne, 10) = TextBox3.Value
.Cells(Derligne, 11) = TextBox4.Value
.Cells(Derligne, 12) = TextBox5.Value
.Cells(Derligne, 16) = TextBox7.Value
End With
End If
'Error handling
On Error GoTo Defaut
Photo = ComboBox4.Value
Image1.Picture = LoadPicture("C:\JCR\Photos Bijoux\" & Photo & ".Jpg")
GoTo FinSub
Defaut:
'Image1.Picture = LoadPicture("C:\JCR\Photos Bijoux\Defaut.Jpg")
'Rafraichir le tableau croisé dynamique
Columns("D:D").NumberFormat = "m/d/yyyy"
Sheets("Stock Par Produit").Select
ActiveWorkbook.RefreshAll
Sheets("SAISIE").Select
Unload FormulaireSaisie
'FormulaireSaisie.Show
ActiveWorkbook.Save
FinSub:
'Error handling
On Error GoTo 0
'Protection
Call ToutProteger
'Désinhibe l'affichage
Application.ScreenUpdating = True
End Sub