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
| Private Sub Mise_à_Jour_Click()
On Error GoTo Err_Mise_à_Jour_Click
Dim MaBase As Database, Tbl_Prospects As Object
Dim Formulaire As String
Dim SqlInsert As String, StrTable As String
Set MaBase = CurrentDb
Set Tbl_Prospects = MaBase.OpenRecordset("Tbl_Prospects", dbOpenTable)
StrTable = "Tbl_Prospects"
Formulaire = "[Formulaires]![Frm_CreatProspects]"
SqlInsert = " INSERT INTO " & StrTable & " (Code_Client, Raison_Sociale, Adresse, Adresse_Cplt)"
SqlInsert = SqlInsert + " SELECT " & Formulaire & "![Code_Client] as Code_Client,"
SqlInsert = SqlInsert + Formulaire & "![Raison_Sociale] as Raison_Sociale,"
SqlInsert = SqlInsert + Formulaire & "![Adresse] as Adresse,"
SqlInsert = SqlInsert + Formulaire & "![Adresse_Cplt] as Adresse_Cplt" & " ;"
Debug.Print SqlInsert
MaBase.Execute SqlInsert, dbFailOnError
MsgBox "Vous avez ajouté " & MaBase.RecordsAffected & " enregistrement."
Debug.Print SqlInsert
Exit_Mise_à_Jour_Click:
Exit Sub
Err_Mise_à_Jour_Click:
MsgBox Err.Description
Resume Exit_Mise_à_Jour_Click
End Sub |
Partager