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
| BeforeUpdate permet d'annuler...
Private Sub Nombre_de_lot_BeforeUpdate(Cancel As Integer)
Dim BD As DAO.Database
Dim RST As DAO.Recordset
Dim SQL As String
Dim LeNumeroDeLotEnCours As Long
Dim intNBLots As Integer
Dim intNombreMaxDeLots As Integer
SQL = "SELECT COUNT([Nombre de lot]) AS NBLOTS FROM T_LotGen _
WHERE [Num Lot] = " & LeNumeroDeLotEnCours & ";"
intNombreMaxDeLots = Me!NombreMaxDeLot
'Je ne sais aps comment tu gères la quantité maxi
Set BD = CurrentDb
Set RST = BD.OpenRecordset(SQL)
With RST
If Not .EOF Then
intNBLots = RST![NBLots]
End If
End With
Set BD = Nothing
Set RST = Nothing
If Me!intNombreMaxDeLots > intNBLots Then
MsgBox "Nombre de lots maxi atteint !", 48, "Contrôle lots"
Cancel = True
End If
End Sub |
Partager