Requete de non correspondance sur deux critères
Bonjour,
J'ai créé un requete de non correspondance "PROJETS_r_Selection" sur deux champs, FK_ID_projet et FK_ID_contact.
Lorsque je la passe en VBA, ca ne fonctionne pas.
Je pense que le probleme vient du champ PROJETS_t_AffectationProjetA_Contacts_temp.FK_ID_projet, qui est cpmplété par une constante, qui est la valeur d'une combo en utilsiant (" SELECT Contacts_t_ListeContacts.ID_Contact, " & int_Projet & " AS FK_ID_projet" & _).
Plus précisément, j'ai notifié le type de valeur comme integer, mais j'ai fait les essais avec string ou variant, et cela ne fonctionne guerre mieux.
Vous trouverez le code dans "LancerRequetePourTrouverContactsAquiAffecterProjet", et une transcription ci-dessous:
Part 1: works fine:
str_SQL_finale = ""
Code:
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
| str_SQL_finale = "INSERT INTO PROJETS_t_AffectationProjetA_Contacts_temp(FK_ID_contact,FK_ID_projet)" & _
" SELECT Contacts_t_ListeContacts.ID_Contact, " & int_Projet & " AS FK_ID_projet" & _
" FROM Contacts_t_ListeContacts" & _
" WHERE " & strAllCriteria & ""
Debug.Print str_SQL_finale
'On vide la table intermediaire
str_Sql = "DELETE FROM PROJETS_t_AffectationProjetA_Contacts_temp"
objConnection.Execute (str_Sql)
'Puis on la complete avec la requete:
objConnection.Execute (str_SQL_finale)
Me.Refresh
'------------------------------------------------------------------------------------------------------------------------------------------------------------------
'la partie qui ne marche aps:
str_SQL_finale2 = "SELECT PROJETS_t_AffectationProjetA_Contacts_temp.FK_ID_contact,PROJETS_t_AffectationProjetA_Contacts_temp.FK_ID_projet" & _
" FROM PROJETS_t_AffectationProjetA_Contacts_temp LEFT JOIN PROJETS_t_AffectationProjetA_Contacts ON" & _
" (PROJETS_t_AffectationProjetA_Contacts_temp.FK_ID_projet = PROJETS_t_AffectationProjetA_Contacts.FK_ID_projet)" & _
" AND (PROJETS_t_AffectationProjetA_Contacts_temp.FK_ID_contact = PROJETS_t_AffectationProjetA_Contacts.FK_ID_contact)" & _
" WHERE PROJETS_t_AffectationProjetA_Contacts.FK_ID_contact Is Null"
Debug.Print str_SQL_finale2
'Puis on la complete avec la requete:
objConnection.Execute (str_SQL_finale2)
Me.Refresh |
Merci d'avance de votre aide.
Etxe.