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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
Private Sub B_Valider_Click()
On Error GoTo Err_B_Valider_Click
Dim Etat As String
Dim stDocName As String
Dim stLinkCriteria As String
Dim Ouv_Ordi As Integer
Dim Con As ADODB.Connection
Dim Rst As ADODB.Recordset
Set Con = New ADODB.Connection
Set Rst = New Recordset
Con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;DataSource=G:\Projet\gestion_stock.mdb"
If IsNull(Me.Serial) Then
MsgBox "la saisie numéro de série de l'ordinateur est obligatoire", vbExclamation, "Attention"
ElseIf IsNull(Me.Date1) Then
MsgBox "La saisie de la date d'emprunt est obligatoire", vbExclamation, "Attention"
ElseIf IsNull(Me.Date2) Then
MsgBox "La saisie de la date de retour est obligatoire", vbExclamation, "Attention"
ElseIf IsNull(Me.IPN) Then
MsgBox "La saisie de l'IPN de l'emprunteur est obligatoire", vbExclamation, "Attention"
ElseIf DCount("[Serial]", "[T_Produit]", "[Serial]='" & Me.Serial & "'") = 0 Then
MsgBox "Cet ordinateur n'est pas enregistré dans la base de donnée ", vbExclamation, "Attention"
Ouv_Ordi = MsgBox("Souhaitez-vous l'enregistrer maintenant ?", vbYesNo, "Information")
ElseIf DLookup("[Etat]", "[T_Produit]", "[Serial]='" & Me.Serial & "'") <> "Stock" Then
Etat = DLookup("[Etat]", "[T_Produit]", "[Serial]='" & Me.Serial & "'")
MsgBox "Opréation impossible car cet ordinateur est en état '" & Etat & "'", vbExclamation, "Attention"
MsgBox "Merci de vérifier vos données"
Else
Con.Open
Rst.Open "Select [Etat] From [T_Produit] Where Serial = '" & Me.Serial & "'", Con, adOpenDynamic, adLockOptimistic
Rst.Fields(0) = "Prêt"
Rst.Update
Rst.Close
Con.Close
DoCmd.GoToRecord , , acNewRec
MsgBox "Opération effecutée avec succès"
End If
If Ouv_Ordi = 6 Then
stDocName = "F_Ordinateur"
DoCmd.OpenForm stDocName, , , stLinkCriteria
ElseIf Ouv_Ordi = 7 Then
MsgBox " Opération annulée "
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
End If
Exit_B_Valider_Click:
Exit Sub |
Partager