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
| Private Sub ValiderContribTR_Click()
Dim test As Boolean
Dim req As String
Dim req2 As String
Dim taffect As Recordset
Dim taffectcont As Recordset
Dim tcontrib As Recordset
Dim ttest As Recordset
Dim tcontribtrav As Recordset
test = VerifierChampsContrib()
If test = True Then 'si tous les champs on été renseignés
Set bd = DBEngine.Workspaces(0).Databases(0)
'on cherche si une contribution travaux n'est pas déjà rattachée au devis
req = "SELECT CODEDEV_1, NUMEROCONT FROM AFFECTERCONTRIB WHERE CODEDEV_1='" & Me.RefDevis & "'"
Set taffect = bd.OpenRecordset(req, DB_OPEN_DYNASET)
Set tcontrib = bd.OpenRecordset("CONTRIBUTION", DB_OPEN_DYNASET)
If taffect.EOF Then 'si aucune contribution n'est associée au devis, on la crée
'création dans la table CONTRIBUTION
tcontrib.AddNew
tcontrib![DateEnvoiCont] = Me.DateEnvoiContribTrav
tcontrib.Update
Debug.Print tcontrib("NUMEROCONT") 'j'ai essayé cela mais je sais pas comment attribuer cette valeur à une variable
'on récupère le numéro de la contribution créée (c'est le numéro maximum de la table)
'req2 = "SELECT max(NUMEROCONT) as MAXNUM FROM CONTRIBUTION"
req2 = "SELECT @@identity AS MAXNUM FROM CONTRIBUTION" 'j'ai essayé aussi cela
Set ttest = bd.OpenRecordset(req2, DB_OPEN_DYNASET)
'création dans la table TRAVAUX
Set tcontribtrav = bd.OpenRecordset("TRAVAUX", DB_OPEN_DYNASET)
tcontribtrav.AddNew
tcontribtrav![NUMEROCONT] = ttest![MAXNUM]
tcontribtrav![TYPEBUDGETTRAV] = RetournerTypeBudget()
tcontribtrav![MONTANTFCTVATRAV] = Me.MontantFCTVA
tcontribtrav![MONTANTFRAISADMINTRAV] = Me.MontantFraisAdmin
tcontribtrav![ETATCONTTRAV] = "E"
tcontribtrav.Update '<- c'est là qu'est l'os
'attribution de cette contribution au devis ... |
Partager