Bonjour,
Débutant SQL je parviens pas à trouver mon erreur..
J'ai une table "Valorisation" dont je veux importer les champs "Reference","MtM (ccy)" dans une table "ValorisationsEOM" qui a trois champs: Reference, MtM et RefDate que je saisie dans un dateTimePicker dans un formulaire.
Au click OK du formulaire je veux donc lancer ma requete qui m'insert les enregistrement de la table Valorisations dans la table ValorisationsEOM en mettant comme ReferenceDate pour chaque enregistrement la date choisie.. mais evidement.. ca marche pas!

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Private Sub Commande0_Click()
 
Dim cat As New ADOX.Catalog
Dim cmd As ADODB.Command
Dim strSQL As String
 
cat.ActiveConnection = CurrentProject.Connection
Set cmd = cat.Procedure("qry_ValorisationsEOM").Command
strSQL = "INSERT INTO ValorisationsEOM (Référence,MtM,RefDate)" & _
        "SELECT [Valorisations].[Reference],  [Valorisations].[MtM (ref ccy)]," & "#"Me.DTPicker1 &"#" & _
         "FROM [Valorisations]"
cmd.CommandText = strSQL
 
Set cat.Views("qry_ValorisationsEOM").Command = cmd
Set cat = Nothing
 
End Sub
Merci par avance pour vos idées