Kaymoi
Messages postés4Date d'inscriptiondimanche 11 décembre 2016StatutMembreDernière intervention13 décembre 2016
-
Modifié par Kaymoi le 13/12/2016 à 12:02
yg_be
Messages postés23235Date d'inscriptionlundi 9 juin 2008StatutContributeurDernière intervention30 septembre 2024
-
13 déc. 2016 à 20:11
Bonjour à tous ,
Désolée de solliciter à nouveau vos compétences et un peu de votre temps mais
me UserForm "entrées/sorties" impossible de faire une sortie complète d'un article.
Exemple : Il me reste 5 références de cet article mais je vends les 5 d'un coup
et que je veux donc les saisir en "sortie". Et bien non ! Cela ne veut pas !
Quelqu'un aurait-il une petite idée où cela pèche svp ?
Option Explicit
Dim m_transaction As String Dim m_invDispo As Long
Private Sub ComboDate_Change()
End Sub
Private Sub ComboProduit_Change() ComboProduit.BackColor = vbWhite m_invDispo = InventaireDisponible(ComboProduit.Text) UpdateInventaireDisponible
End Sub
Private Sub ComboRef_Change() ComboRef.BackColor = vbWhite End Sub
Private Sub CValider_Click() Dim valide As Boolean valide = True
If ComboRef.ListIndex = -1 Then ComboRef.BackColor = vbRed: valide = False If ComboProduit.ListIndex = -1 Then ComboProduit.BackColor = vbRed: valide = False If Len(TQte) = 0 Then TQte.BackColor = vbRed: valide = False If Len(TCoutUnitaire) = 0 Then TCoutUnitaire.BackColor = vbRed: valide = False If Len(TCoutTotal) = 0 Then TCoutTotal.BackColor = vbRed: valide = False If m_transaction = "Sortie" And Val(TQte) > Val(LInvQte.Caption) Then TQte.BackColor = vbRed: valide = False
If valide Then With Sheets("Journal des stocks") With .Range("A" & .Rows.Count).End(xlUp).Offset(1)
With .Offset(0): .Value = CDate(ComboDate.Text): .NumberFormat = "yyyy/mm/dd": End With .Offset(, 1) = IIf(m_transaction = "Entree", "Entrée", "Sortie") .Offset(, 2) = ComboProduit.Text .Offset(, 3) = ComboProduit.List(ComboProduit.ListIndex, 1) .Offset(, 4) = ComboRef.Text With .Offset(, 5): .Value = Val(TQte): .NumberFormat = "### ### ##0": End With With .Offset(, 6): .Value = Val(TCoutUnitaire): .NumberFormat = "_-* # ##0.00\ ""€""_-;-* # ##0.00\ ""€""_-;_-* ""-""??\ ""€""_-;_-@_-": End With With .Offset(, 7): .Value = Val(TCoutTotal): .NumberFormat = "_-* # ##0.00\ ""€""_-;-* # ##0.00\ ""€""_-;_-* ""-""??\ ""€""_-;_-@_-": End With End With End With
Unload Me End If
End Sub
Private Sub Onglets_Change() m_transaction = Onglets.SelectedItem.Name
Select Case m_transaction Case "Entree": TRef.Caption = "CATEGORIE:" Case "Sortie": TRef.Caption = "CATEGORIE:" End Select
UpdateInventaireDisponible
End Sub
Private Sub TCoutTotal_Change() Call UpdateCoutUnitaire End Sub
Private Sub TCoutTotal_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) Dim char As String, adpoint As Long
TCoutTotal.BackColor = vbWhite
char = Chr(KeyAscii) adpoint = InStr(1, TCoutTotal.Text, Application.DecimalSeparator) If Not IsNumeric(char) Then KeyAscii = 0 If char = "0" And Len(TCoutTotal.Text) = 0 Then KeyAscii = 0 If adpoint = 0 Then If char = Application.DecimalSeparator Then KeyAscii = Asc(char) If Len(TCoutTotal.Text) = 0 Then TCoutTotal.Text = "0" End If Else If Len(TCoutTotal.Text) >= 3 And Len(TCoutTotal.Text) - InStr(1, TCoutTotal.Text, Application.DecimalSeparator) >= 2 Then KeyAscii = 0 End If
End Sub
Private Sub TCoutUnitaire_Change() Call UpdateCoutTotal End Sub
Private Sub TCoutUnitaire_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) Dim char As String, adpoint As Long
TCoutUnitaire.BackColor = vbWhite
char = Chr(KeyAscii) adpoint = InStr(1, TCoutUnitaire.Text, Application.DecimalSeparator) If Not IsNumeric(char) Then KeyAscii = 0 If char = "0" And Len(TCoutUnitaire.Text) = 0 Then KeyAscii = 0 If adpoint = 0 Then If char = Application.DecimalSeparator Then KeyAscii = Asc(char) If Len(TCoutUnitaire.Text) = 0 Then TCoutUnitaire.Text = "0" End If Else If Len(TCoutUnitaire.Text) >= 3 And Len(TCoutUnitaire.Text) - InStr(1, TCoutUnitaire.Text, Application.DecimalSeparator) >= 2 Then KeyAscii = 0 End If End Sub
Private Sub TQte_Change() If Val(TQte) = 0 Then TQte = "" Else If Len(TCoutUnitaire) > 0 Then UpdateCoutTotal ElseIf Len(TCoutTotal) > 0 Then UpdateCoutUnitaire End If End If Call UpdateInventaireDisponible End Sub
If Val(LInvQte.Caption) < 0 Then LInvQte.BorderColor = vbRed LInv.ForeColor = vbRed End If End Sub Private Sub TQte_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) TQte.BackColor = vbWhite If Not IsNumeric(Chr(KeyAscii)) Then KeyAscii = 0 End Sub
Private Sub UserForm_Initialize() Onglets.Tabs.Clear Onglets.Tabs.Add "Entree", "Entrée" Onglets.Tabs.Add "Sortie", "Sortie" Onglets.SelectedItem.Index = 0 Call RemplirComboRef(ComboRef) Call RemplirComboProduit(ComboProduit) Call RemplirComboDate(ComboDate) End Sub
Private Sub UpdateCoutUnitaire() If Len(TQte) > 0 Then TCoutUnitaire.Text = Round(CDbl(Val(TCoutTotal) / Val(TQte)), 2): TCoutUnitaire.BackColor = vbWhite End Sub Private Sub UpdateCoutTotal() If Len(TQte) > 0 Then TCoutTotal.Text = Round(CDbl(Val(TCoutUnitaire) * Val(TQte)), 2): TCoutTotal.BackColor = vbWhite End Sub