Petit problème de synthaxe avec requête UPDATE basée sur deux tables

Résolu
cs_Famas54 Messages postés 59 Date d'inscription mardi 12 septembre 2006 Statut Membre Dernière intervention 21 août 2009 - 13 août 2008 à 12:05
cs_Famas54 Messages postés 59 Date d'inscription mardi 12 septembre 2006 Statut Membre Dernière intervention 21 août 2009 - 14 août 2008 à 13:30
Bonjour,

Je cherche à faire une update des champs de certaines lignes de ma table principale Noind avec les donnéés contenues dans une autre table: table_stockage_newfundsall en fonction du numéro NoInd qui est la clé primaire de chacune des deux table. Tout est respecté en terme d'intégrité référentielle et de configuration des différents champs mais je ne suis pas parvenu à exécuter ma requête dans le but de retrouver les informations relatives aux codes NoInd de table_stockage_newfundsall  dans ma table Noind, Je n'ai aucun renvoi d'erreur, rien ne change suite à l'execution de la requête.

Voilà ce que ça donne:

DoCmd.RunSQL "UPDATE [Noind], table_stockage_newfundsall
SET Noind.Resp_compte = table_stockage_newfundsall.Resp_compte,
Noind.Sub_Fund_name = table_stockage_newfundsall.Sub_Fund_name,
Noind.Pays_invest_Principal = table_stockage_newfundsall.Pays_invest_Principal,
Noind.Type_prod_investi = table_stockage_newfundsall.Type_prod_investi,
Noind.Devise_principale_NoInd = table_stockage_newfundsall.Devise_principale_NoInd,
Noind.Date_creation = table_stockage_newfundsall.Date_creation
WHERE [Noind.NoInd] = table_stockage_newfundsall.NoInd;"

Je n'ai vraiment pas idée de ce qui cloche et la raison pour laquelle rien ne change suite à ma requête.

4 réponses

LIBRE_MAX Messages postés 1402 Date d'inscription mardi 1 mai 2007 Statut Membre Dernière intervention 7 octobre 2012 6
13 août 2008 à 16:58
tentes l' affaire utrement.
Dim dbs As Data   Base
Set dbs = CurrentDb
Dim strSQL As String

strSql="UPDATE [Noind] INNER JOIN table_stockage_newfundsall ON [Noind.NoInd] = table_stockage_newfundsall.NoInd
SET Noind.Resp_compte = table_stockage_newfundsall.Resp_compte,
Noind.Sub_Fund_name = table_stockage_newfundsall.Sub_Fund_name,
Noind.Pays_invest_Principal = table_stockage_newfundsall.Pays_invest_Principal,
Noind.Type_prod_investi = table_stockage_newfundsall.Type_prod_investi,
Noind.Devise_principale_NoInd = table_stockage_newfundsall.Devise_principale_NoInd,
Noind.Date_creation = table_stockage_newfundsall.Date_creation;"

dbs.Execute strSQL, dbFailOnError
Msgbox dbs.RecordsAffected & " record(s) mis à jour"
Set dbs = Nothing

Si l' erreur persite, vérifie la synthaxe notament au niveau des espaces après les virgules.

<hr />... Y'en a même qui disent qu'ils l'ont vu voler.
3
LIBRE_MAX Messages postés 1402 Date d'inscription mardi 1 mai 2007 Statut Membre Dernière intervention 7 octobre 2012 6
13 août 2008 à 14:47
Salut,
Si je souviens bien, je t' ai déjà fais remarqué qu" encas de tables liées il faut mettre en évidence la jointure.
INNER JOIN au début et sans clause where sauf si
le critère concerne un champ autre que la clé.

DoCmd.RunSQL "UPDATE [Noind] INNER JOIN table_stockage_newfundsall ON [Noind.NoInd] = table_stockage_newfundsall.NoInd
SET Noind.Resp_compte = table_stockage_newfundsall.Resp_compte,
Noind.Sub_Fund_name = table_stockage_newfundsall.Sub_Fund_name,
Noind.Pays_invest_Principal = table_stockage_newfundsall.Pays_invest_Principal,
Noind.Type_prod_investi = table_stockage_newfundsall.Type_prod_investi,
Noind.Devise_principale_NoInd = table_stockage_newfundsall.Devise_principale_NoInd,
Noind.Date_creation = table_stockage_newfundsall.Date_creation
<strike>WHERE [Noind.NoInd] = table_stockage_newfundsall.NoInd</strike>;"

<hr />... Y'en a même qui disent qu'ils l'ont vu voler.
0
cs_Famas54 Messages postés 59 Date d'inscription mardi 12 septembre 2006 Statut Membre Dernière intervention 21 août 2009 2
13 août 2008 à 16:25
En fait j'ai tout d'abord tenté avec cette syntaxe là mais un autre problème revient tout le temps, un runtime error 3144 Syntax error in UPDATE statement que je ne suis pas parvenu à éviter alors j'ai tenté autre chose.
0
cs_Famas54 Messages postés 59 Date d'inscription mardi 12 septembre 2006 Statut Membre Dernière intervention 21 août 2009 2
14 août 2008 à 13:30
Cela fonctionne pile poil, le petit message d'information en plus.
C'est curieux que la requête fonctionne comme cela et pas avec la synthaxe précédente.

Maintenant je dois réutiliser cette structure pour une autre requête quasiment du même genre avec une condition WHERE dans l'update, en espérant que cela est possible.

Merci bien.
0
Rejoignez-nous