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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
Private Sub C4_Click()
Dim lig&, i&, memo$
If ListBox1.ListIndex = -1 Then Exit Sub
Dim fichierdocument As String
Dim iddocument As Long
Dim feuille As String
Dim chemin As String
Dim Cn As ADODB.Connection
Dim Fichier As String
Dim texte_SQL As String
' variables de controle
Dim typedoc As String
Dim numdoc As Long
Dim datedoc As String
Dim nomclient As String
Dim numprojet As String
Dim titreprojet As String
Dim totprojet As Long
Dim ac As Long
Dim totfacture As Long
typedoc = Controls("T2")
numdoc = Controls("T3")
datedoc = Controls("T4")
nomclient = Controls("T5")
numprojet = Controls("T6")
titreprojet = Controls("T7")
totprojet = Controls("T8")
ac = Controls("T9")
totfacture = Controls("T10")
chemin = Worksheets("INPUT").Range("A19")
fichierdocument = "db_document.xlsx"
iddocument = Worksheets("Export").Cells(ListBox1.List(ListBox1.ListIndex, 9), 21).Value
Fichier = chemin & fichierdocument
feuille = "DOCUMENT"
Set Cn = New ADODB.Connection
'--- Connexion ---
With Cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" _
& Fichier & ";Extended Properties=""Excel 12.0;HDR=YES;"""
.Open
End With
'-----------------
'Définit la requête.
'/!\ Attention à ne pas oublier le symbole $ après le nom de la feuille.
texte_SQL = "UPDATE [" & feuille & "$] SET NUM_DOCUMENT = " & numdoc & ", " & _
" TYPE_DOCUMENT = '" & Replace(typedoc, "'", "''") & "', " & _
" DATE_DOCUMENT = '" & Replace(datedoc, "'", "''") & "', " & _
" NOM_CLIENT = '" & Replace(nomclient, "'", "''") & "', " & _
" NUM_PROJET = '" & Replace(numprojet, "'", "''") & "', " & _
" TITRE_PROJET = '" & Replace(titreprojet, "'", "''") & "', " & _
" TOTAL_PROJET = " & Replace(totprojet, "'", "''") & ", " & _
" ACOMPTE = " & Replace(ac, "'", "''") & ", " & _
" TOTAL_FACTURE = " & Replace(totfacture, "'", "''") & " WHERE ID = " & iddocument
Cn.Execute texte_SQL
'texte_SQL = "UPDATE [" & feuille & "$] SET TYPE_DOCUMENT = '" & typedoc & "' WHERE ID = " & iddocument
'Cn.Execute texte_SQL
'--- Fermeture connexion ---
Cn.Close
Set Cn = Nothing
memo = T1
Unload Documentrechercheform
Documentrechercheform.T1 = memo
Documentrechercheform.Show |
Partager