Bonsoir à tous,
Je sais ce sujet déjà de multiples fois abordé.... mais j'ai un petit souci d'adaptation
le modèle est celui-ci:
https://access.developpez.com/source...QLLigneColonne
dans ma table j'ai ajouté une nouvelle colonne date
Tbl_Projet
NomParticipant CodeProjet NomProjet DateProjet Olivier 1 Poterie 18/01/2022 franck 2 Bois 18/01/2022 Daniel 1 Poterie 22/01/2021 Denis 1 Poterie 22/01/2021 Thierry 2 Bois 18/01/2022 Thierry 1 Poterie 22/01/2021
ma requête R01:
Affichage R01
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 SELECT DISTINCT Tbl_projet.CodeProjet, RecupParticipant([CodeProjet]) AS LesParticipants, Tbl_projet.DateProjet FROM Tbl_projet GROUP BY Tbl_projet.CodeProjet, RecupParticipant([CodeProjet]), Tbl_projet.DateProjet;
R01
R01 CodeProjet LesParticipants DateProjet 1 Olivier;Daniel;Denis;Thierry 22/01/2021 1 Olivier;Daniel;Denis;Thierry 18/01/2022 2 franck;Thierry 18/01/2022
Module1
Le problème c'est le résultat de la requête, les participants sont en doublon lorsque des dates diffèrent!
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 Public Function RecupParticipant(CodeProjet As Long) As String Dim res As DAO.Recordset Dim SQL As String 'Selectionne les participant du projet SQL = "SELECT NomParticipant FROM Tbl_Projet WHERE CodeProjet=" & CodeProjet Set res = CurrentDb.OpenRecordset(SQL) 'Concatene les différents enregistrements While Not res.EOF RecupParticipant = RecupParticipant & res.Fields(0).Value & ";" res.MoveNext Wend 'Enleve le dernier espace RecupParticipant = Left(RecupParticipant, Len(RecupParticipant) - 1) 'libere la mémoire Set res = Nothing End Function
Est-ce normal, autrement dit, est-ce que ce module et cette requête sont la bonne approche ?
MERCI !
Partager