Bonjour,
Tout d'abord, merci pour toutes ressources !
Je suis néophyte et je cherche à adapter le code / tuto Concaténer plusieurs enregistrements dans une seule colonne .
Pour reprendre l'exemple, il y a une table intermédiaire "participer".
Table Projet
Table participant
Table participer
Cardinalités
Lorsque j'exécute la requête, contrairement au tuto, Access me demande une valeur en input et je ne comprends pas pourquoi.
Si je renseigne 1
Le résultat que j'obtiens est celui ci-dessous :
Cela correspond aux enregistrements de l'ID 1 a priori mais je ne comprends pas la confusion avec le "DISTINCT".
Cela fait un moment que je cherche et j'ai vraiment besoin d'adapter, à plusieurs endroits, cette concaténation (dont un endroit avec des retours chariots > mais ca fera peut-être l'objet d'un autre post après recheche préalab).
Module
Requête :
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
18
19 Public Function RecupParticipant(Projet As String) As String Dim res As DAO.Recordset Dim SQL As String 'Selectionne les participant du projet SQL = "SELECT Participant.PrenomParticipant, Participant.NomParticipant FROM Projet INNER JOIN (Participant INNER JOIN participer ON Participant.id_Participant = participer.id_Participant) ON Projet.id_projet = participer.id_projet WHERE participer.id_projet =" & Projet Set res = CurrentDb.OpenRecordset(SQL) 'Concatene les différents enregistrement While Not res.EOF RecupParticipant = RecupParticipant & res.Fields(0).Value & " " & res.Fields(1).Value & " ; " '& " " & res.Fields(2).Value res.MoveNext Wend 'Enleve le dernier espace RecupParticipant = Left(RecupParticipant, Len(RecupParticipant) - 2) 'libere la mémoire Set res = Nothing End Function
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 SELECT DISTINCT participer.id_projet, Recupparticipant(Projet) AS LesParticipants FROM Projet INNER JOIN participer ON Projet.id_projet = participer.id_projet;
Pourriez-vous m'apporter votre expertise SVP ?
Je vous remercie
André
Partager