1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| Private Sub btEnregistrer_Click()
Dim sSql As String
Dim StockAlerte As Long
'Est-ce complet ?
If IsNull(Me.txtDate) Or Nz(Me.txtQuant, 0) = 0 Or Nz(Me.txtImputation, 0) = 0 Then
MsgBox "Un des champs obligatoires n'est pas rempli", vbCritical
Exit Sub
End If
'Maj tSorties
sSql = "INSERT INTO tSorties ( SortieDate, SortieQuant, SortieImputation, CMUP, tArticlesFK ) " _
& "SELECT #" & Format(Me.txtDate, "mm/dd/yy") & "# AS Expr1, " _
& Me.txtQuant & " AS Expr2, " _
& """" & Me.txtImputation & """ AS Expr3, " _
& Replace(Me.txtCMUP, ",", ".") & " AS Expr4, " _
& Me.CboArticle & " As Expr5;"
DoCmd.SetWarnings False
DoCmd.RunSQL sSql
DoCmd.SetWarnings True
'Réinitialiser pour une nouvelle sortie éventuelle
Me.CTNRsfSortiesDetail.Requery
Me.txtDate = Null: Me.txtQuant = Null: Me.txtImputation = Null
Me.txtStock = StockADate(Me.CboArticle, Format(Date, "mm/dd/yyyy"))
'Vérifier que le seuil n'est pas franchi
StockAlerte = DLookup("StockAlerte", "tArticles", "tArticlePK=" & Me.CboArticle)
If StockADate(Me.CboArticle, Date) <= StockAlerte Then
MsgBox "Réapprovisionnez cet article !" & Chr(13) & Chr(10) _
& "Stock d'alerte : " & StockAlerte & "."
End If
End Sub |
Partager