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
| Private Sub cmd_Save_Click()
'Ajoute l'information à la table historique (VENTE)
'Vérification
If IsNull(Me.Listevendeur.Value) Then
Dim ErreurMissing1
ErreurMissing1 = MsgBox("Vendeur non sélectionné", vbDefaultButton1 + vbOKOnly, "Erreur")
Else
If IsNull(Me.Matricule.Value) Then
Dim ErreurMissing2
ErreurMissing2 = MsgBox("Usager non sélectionné", vbDefaultButton1 + vbOKOnly, "Erreur")
Else
If IsNull(Me.Modifiable52.Value) Then
Dim ErreurMissing3
ErreurMissing3 = MsgBox("Titre non sélectionné", vbDefaultButton1 + vbOKOnly, "Erreur")
Else
'Inscription BD
Dim StrDate, StrTime, StrCName, StrVendeur, StrVente, StrCommentaire, StrNom, StrPrenom
StrDate = VBA.Format(StrConv(Me.Auto_Date.Value, vbLowerCase), "\#mm\/dd\/yyyy\#")
StrTime = VBA.Format(DateTime.Now, "hh:MM:ss")
StrCName = VBA.Environ("computername")
StrVendeur = Me.Listevendeur.Value
StrVente = "Vente"
StrCommentaire = InputBox("Nom sur le chèque et numéro du chèque", "Information sur le chèque")
StrCommentaire = Replace(StrCommentaire, "'", "")
StrNom = Replace(Me.Nom, "'", "")
StrPrenom = Replace(Me.Prenom, "'", "")
'Vérification si le titre à déjà été loader avant (VOICI LA PORTION OU J'ESSAIE DE VÉRIFIER SI LE TITRE EXISTE)
Dim db As Database
Dim rs As Recordset
Dim StrSQL As String
StrSQL = "SELECT Historique.MatriculeUsager, Historique.MoisService, Historique.AnneeService FROM Historique WHERE Historique.MatriculeUsager = '" & Me.Matricule & "' AND Historique.MoisService = '" & Me.Texte62 & "' AND Historique.AnneeService ='" & Me.Texte66 & "'"
Set db = CurrentDb()
Set rs = db.OpenRecordset(StrSQL, dbOpenDynaset)
If Not rs.EOF Then
Dim MsgWarning
MsgWarning = MsgBox("Le titre à déjà été créé pour cet utilisateur", vbDefaultButton1 + vbInformation, "Erreur")
Else
'inscription à la base de registre (CETTE PORTION FONCTIONNE)
CurrentDb.Execute "INSERT INTO Historique (DateVente, TitreVendu, MoisService, AnneeService, CoutTitreVendu, MatriculeUsager, NomUsager, PrenomUsager, HeureVente, Vendeur, Emplacement, EtatTitre, Commentaire) " & _
" VALUES (" & StrDate & ",'" & Me.Texte62 & "','" & Me.Texte64 & "','" & Me.Texte66 & "','" & Me.Texte68 & "','" & Me.Matricule & "','" & StrNom & "','" & StrPrenom & "','" & StrTime & "','" & StrVendeur & "','" & StrCName & "','" & StrVente & "','" & StrCommentaire & "')"
End If
'Rafraichie la liste dans le sous formulaire historique
Historique_sous_formulaire.Form.Requery
End If
End If
End If
rs.Close
Set rs = Nothing
Set db = Nothing
End Sub |
Partager