Problème de virgule avec UPDATE

Résolu
andy331 Messages postés 45 Date d'inscription mercredi 11 novembre 2009 Statut Membre Dernière intervention 11 juin 2010 - 20 janv. 2010 à 17:35
andy331 Messages postés 45 Date d'inscription mercredi 11 novembre 2009 Statut Membre Dernière intervention 11 juin 2010 - 21 janv. 2010 à 16:13
Bonjour j'ai une erreur que j'arrive pas traiter et je voudrais que quelqu'un m'aide à la trouvée.
Quand j'appuie sur le bouton valider une console s'affiche et me dis ceci:
"Erreur exécution '3075'
Erreur de syntaxe (virgule) dans l'expression << Nom_entreprise = maValeur modifier etc....>>
C'est à dire que toutes mes valeurs sont reconnu mais je comprends pas cette erreur celle-ci!
Merci de bien vouloir me venir en aide!!!


Code Visual Basic :
sql_Valider "Update T_Prospection Set Nom_entreprise '" & Forms!client.TxtNomSociete & "', Fax= '" & Forms!client.TxtFaxSociete & "',Telephone = '" & Forms!client.TxTtelSociete & "', Mail = '" & Forms!client.TxtMailSociete & "', Siege_social= '" & Forms!client.TxtSiegeSocialAdresse & "', Adresse = '" & Forms!client.TxtAdresse1 & "', Contact_nom = '" & Forms!client.TxtNomPrenom1 & "', Contact_poste = '" & Forms!client.TxtPoste1 & "', Contact_mail = '" & Forms!client.TxtMail1 & "', Contact_telephone_direct = '" & Forms!client.TxtTelDirect1 & "', Contact_telephone_portable = '" & Forms!client.TxtTelPortable1 & "', Mail_envoye = '" & Forms!client.TxtDateMailEnvoye & "', Contact_telephone = '" & Forms!client.TxtDateContactTel & "', Contact_terrain = '" & Forms!client.TxtDateContactTerrain & "', RDV_realise = '" & Forms!client.TxtDateRdvRealise & "', Date_de_relance = '" & Forms!client.TxtDateARelancer & "', Num_entreprise = '" & Forms!client.TxtIndiceClient & "'"
sql_Valider sql_Valider & " where Nom_entreprise '" & Forms!client.TxtNomSociete & " ',Fax= '" & Forms!client.TxtFaxSociete & "',Telephone = '" & Forms!client.TxTtelSociete & "', Mail = '" & Forms!client.TxtMailSociete & "', Siege_social= '" & Forms!client.TxtSiegeSocialAdresse & "', Adresse = '" & Forms!client.TxtAdresse1 & "', Contact_nom = '" & Forms!client.TxtNomPrenom1 & "', Contact_poste = '" & Forms!client.TxtPoste1 & "', Contact_mail = '" & Forms!client.TxtMail1 & "', Contact_telephone_direct = '" & Forms!client.TxtTelDirect1 & "', Contact_telephone_portable = '" & Forms!client.TxtTelPortable1 & "', Mail_envoye = '" & Forms!client.TxtDateMailEnvoye & "', Contact_telephone = '" & Forms!client.TxtDateContactTel & "', Contact_terrain = '" & Forms!client.TxtDateContactTerrain & "', RDV_realise = '" & Forms!client.TxtDateRdvRealise & "', Date_de_relance = '" & Forms!client.TxtDateARelancer & "', Num_entreprise = '" & Forms!client.TxtIndiceClient & "';"
DoCmd.RunSQL (sql_Valider)
MsgBox ("Modification effectuer")
[quote][quote][quote][quote][quote][quote][quote]
/quote/quote/quote/quote/quote/quote/quote

4 réponses

andy331 Messages postés 45 Date d'inscription mercredi 11 novembre 2009 Statut Membre Dernière intervention 11 juin 2010
21 janv. 2010 à 16:13
sql_Valider = "Update T_Prospection Set Nom_entreprise = '" & Forms!client.TxtNomSociete & "', Fax= '" & Forms!client.TxtFaxSociete & "',Telephone = '" & Forms!client.TxTtelSociete & "', Mail = '" & Forms!client.TxtMailSociete & "', Siege_social= '" & Forms!client.TxtSiegeSocialAdresse & "', Adresse = '" & Forms!client.TxtAdresse1 & "', Contact_nom = '" & Forms!client.TxtNomPrenom1 & "', Contact_poste = '" & Forms!client.TxtPoste1 & "', Contact_mail = '" & Forms!client.TxtMail1 & "', Contact_telephone_direct = '" & Forms!client.TxtTelDirect1 & "', Contact_telephone_portable = '" & Forms!client.TxtTelPortable1 & "', Mail_envoye = '" & Forms!client.TxtDateMailEnvoye & "', Contact_telephone = '" & Forms!client.TxtDateContactTel & "', Contact_terrain = '" & Forms!client.TxtDateContactTerrain & "', RDV_realise = '" & Forms!client.TxtDateRdvRealise & "', Date_de_relance = '" & Forms!client.TxtDateARelancer & "', Num_entreprise = '" & Forms!client.TxtIndiceClient & "'"
sql_Valider sql_Valider & " WHERE Num_entreprise Forms!client.TxtIndiceClient"


Elle marche j'avais juste mal orthographiée certain mon
Je te remercie pour ton aide
3
PCPT Messages postés 13272 Date d'inscription lundi 13 décembre 2004 Statut Membre Dernière intervention 3 février 2018 47
20 janv. 2010 à 18:14
salut,


tu fais un UPDATE, donc une mise à jour d'un enregistrement existant

1 => pourquoi "tout mettre à jour", si tu le fais pour (WHERE) l'enregistrement a déjà tous les champs actuels?

autrement dit le seul moyen de faire l'update (d'avoir une raison de le faire) est de modifier une des valeurs, ce qui fait qu'on n'a plus d'enregistrement concordant, donc rien à updater

2 => plusieurs CRITèRES se séparent par AND (après le where), pas par des virgules. voilà la raison du message d'erreur

mais de toute façon tu n'en as pas besoin (ces critères). l'ID suffit


une petite fonction pratique :

Function sq(ByVal s As String) As String 'Safe Quote
    sq = "'" & Replace(s, "'", "''") & "'"
End Function


et ta requête devient :
With Forms!client
    sql_Valider = "UPDTAE T_Prospection " & _
                  "SET Nom_entreprise " & sq(.TxtNomSociete.Text) & ", Fax " & sq(.TxtFaxSociete.Text) & ", Telephone = " & sq(.TxTtelSociete.Text) & ", Mail = " & sq(.TxtMailSociete.Text) & ", Siege_social = " & sq(.TxtSiegeSocialAdresse.Text) & ", Adresse = " & sq(.TxtAdresse1.Text) & ", Contact_nom = " & sq(.TxtNomPrenom1.Text) & ", Contact_poste = " & sq(.TxtPoste1.Text) & ", Contact_mail = " & sq(.TxtMail1.Text) & ", Contact_telephone_direct = " & sq(.TxtTelDirect1.Text) & ", Contact_telephone_portable = " & sq(.TxtTelPortable1.Text) & ", Mail_envoye = " & sq(.TxtDateMailEnvoye.Text) & ", Contact_telephone = " & sq(.TxtDateContactTel.Text) & ", Contact_terrain = " & sq(.TxtDateContactTerrain.Text) & ", RDV_realise = " & sq(.TxtDateRdvRealise.Text) & ", Date_de_relance = #" & .TxtDateARelancer & "# " & _
                  "WHERE Num_entreprise = " & .TxtIndiceClient & ";"
End With


++
[hr]
0
andy331 Messages postés 45 Date d'inscription mercredi 11 novembre 2009 Statut Membre Dernière intervention 11 juin 2010
21 janv. 2010 à 11:16
ça marche pas!!
Il n'y aurait pas une façon la plus simple possible de la faire?
Merci
0
Renfield Messages postés 17287 Date d'inscription mercredi 2 janvier 2002 Statut Modérateur Dernière intervention 27 septembre 2021 74
21 janv. 2010 à 12:14
quelle requete as tu soumise ?


Renfield - Admin CodeS-SourceS - MVP Visual Basic
0
Rejoignez-nous