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
| Private Sub Exporter_Click()
Dim dbs As DAO.Database
Dim rst As DAO.Recordset, rst1 As DAO.Recordset, rst2 As DAO.Recordset
Dim strSql As String
Set dbs = CurrentDb
strSql = "SELECT * FROM Commande WHERE Selection = True "
Set rst = dbs.OpenRecordset(strSql, dbOpenDynaset)
'test = DLookup("[PoidsTH]", "base", "[Référence] = '" & extraitG & "' ")
strSql = "SELECT * FROM base WHERE [Référence] = '" & Left(rst.Fields("NumArticle"), InStr(rst.Fields("NumArticle"), Right(rst.Fields("NumArticle"), 6)) - 1) & "'"
Set rst1 = dbs.OpenRecordset(strSql, dbOpenDynaset)
'test = rst1.Fields("PoidsTH")
'Filière = DLookup("[Filiere]", "Feuil2", "[Référence] = '" & extraitG & "' ")
strSql = "SELECT * FROM Feuil2 WHERE [Référence] = '" & Left(rst.Fields("NumArticle"), InStr(rst.Fields("NumArticle"), Right(rst.Fields("NumArticle"), 6)) - 1) & "'"
Set rst2 = dbs.OpenRecordset(strSql, dbOpenDynaset)
'filière = rst2.Fields("Filiere")
dbs.Execute "UPDATE Commande SET Laquage = '" & Left(Right(rst.Fields("NumArticle"), 6), 2) & "'" _
& " SET PoidsTH = '" & rst1.Fields("PoidsTH") & "'" _
& " SET Ref = '" & Left(rst.Fields("NumArticle"), InStr(rst.Fields("NumArticle"), Right(rst.Fields("NumArticle"), 6)) - 1) & "'" _
& " SET Longueur = '" & Right(rst.Fields("NumArticle"), 4) & "'" _
& " SET NumFiliere = '" & rst2.Fields("Filiere") & "'" _
& " WHERE Selection = True", dbFailOnError
dbs.Execute "INSERT INTO EnAttPlanification(NumOrigine, Numero, NumArticle, CodeVariante, DateCommande, DateLivDemander, QteManquante, QteRestante, QtePretDepart, PoidsManquant, Observations, NomDestinataire, NumDestination, Qte, Longueur, Ref, PoidsTH, Laquage, NumFiliere)" _
& " SELECT NumOrigine, Numero, NumArticle, CodeVariante, DateCommande, DateLivDemander, QteManquante, QteRestante, QtePretDepart, PoidsManquant, Observations, NomDestinataire, NumDestination, Qte, Longueur, Ref, PoidsTH, Laquage, NumFiliere" _
& " FROM Commande" _
& " WHERE Selection = True", dbFailOnError
dbs.Execute " DELETE * FROM Commande WHERE Selection = True", dbFailOnError
Me.Requery
Me.Refresh
rst2.Close
rst1.Close
rst.Clone
dbs.Close
Set rst2 = Nothing
Set rst1 = Nothing
Set rst = Nothing
Set dbs = Nothing
End Sub |
Partager