Bonjour à tous,
Voila alors j'ai un formulaire de recherche multi-critères et j'en suis au stade où je veux qu'un même candidat n'apparaisse qu'une seule et unique fois dans mon tableau de résultat (appelé lstResults).
Je me base sur ce tutoriel là : http://access.developpez.com/sources...QLLigneColonne
mais je n'arrive pas à l'adapter à mon code à moi.
Vous trouverez en pièce jointe les relations entre mes tables, qui est une information capitale pour comprendre le problème.
voici mon code me permettant de concaténer les différentes langues parlées par une personne en une seule colonne (normalement...) :
Code SQL : 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 Recuplangue(candidat_id As Long) As String Dim res As DAO.Recordset Dim SQL As String SQL = "SELECT T_Langue.langue FROM T_Langue LEFT JOIN T_Candidat_Langue WHERE T_Candidat_Langue.candidat_id=" & _ Chr(34) & candidat_id & Chr(34) Set res = CurrentDb.OpenRecordset(SQL) While Not res.EOF Recuplangue = Recuplangue & res.Fields(0).Value & ";" res.MoveNext Wend Recuplangue = Left(Recuplangue, Len(Recuplangue) - 1) Set res = Nothing End Function
et voici mon code qui calcule mon SQL et qui appelle le module précédent (appelé Recuplangue) :
Code SQL : 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
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52 Private Sub RefreshQuery() Dim SQL As String SQL = "SELECT T_Candidat.candidat_id, T_Candidat.nom, T_Candidat.prenom, T_Candidat.age, T_Candidat.date_de_naissance, T_Position.position, T_Discipline.discipline, T_Phase.phase, T_Venant_de.venant_de, T_Année_expérience.experience, Recuplangue(canditat_id) as Langue, T_Détails_Discipline.details_discipline " & _ "FROM ((((((((T_Candidat " & _ "LEFT JOIN T_Position ON T_Candidat.position_id = T_Position.position_id) " & _ "LEFT JOIN T_Discipline ON T_Candidat.discipline_id = T_Discipline.discipline_id) " & _ "LEFT JOIN T_Phase ON T_Candidat.phase_id = T_Phase.phase_id) " & _ "LEFT JOIN T_Venant_de ON T_Candidat.venant_de_id = T_Venant_de.venant_de_id) " & _ "LEFT JOIN T_Année_expérience ON T_Candidat.annee_experience_id = T_Année_expérience.annee_experience_id) " & _ "LEFT JOIN T_Candidat_Langue ON T_Candidat.candidat_id = T_Candidat_Langue.candidat_id) " & _ "LEFT JOIN T_Langue ON T_Candidat_Langue.langue_id = T_Langue.langue_id) " & _ "LEFT JOIN T_Candidat_Détails_Discipline ON T_Candidat.candidat_id = T_Candidat_Détails_Discipline.candidat_id) " & _ "LEFT JOIN T_Détails_Discipline ON T_Candidat_Détails_Discipline.details_discipline_id = T_Détails_Discipline.details_discipline_id " & _ "WHERE T_Candidat.candidat_id <> 0 " If Me.chknom Then SQL = SQL & "And T_Candidat.nom = '" & Me.cmbrechnom & "' " End If If Me.chkage Then SQL = SQL & "And T_Candidat.age like '" & Me.txtrechage & "*' " End If If Me.chkposition Then SQL = SQL & "And T_Position.position = '" & Me.cmbrechposition & "' " End If If Me.chkdiscipline Then SQL = SQL & "And T_Discipline.discipline = '" & Me.cmbrechdiscipline & "' " End If If Me.chkphase Then SQL = SQL & "And T_Phase.phase = '" & Me.cmbrechphase & "' " End If If Me.chkvenantde Then SQL = SQL & "And T_Venant_de.venant_de = '" & Me.cmbrechvenantde & "' " End If If Me.chkexperience Then SQL = SQL & "And T_Année_expérience.experience = '" & Me.cmbrechexperience & "' " End If If Me.chklangue Then SQL = SQL & "And T_Langue.langue = '" & Me.cmbrechlangue & "' " End If If Me.chkdetailsdiscipline Then SQL = SQL & "And T_Détails_Discipline.details_discipline = '" & Me.cmbrechdetailsdiscipline & "' " End If SQL = SQL & ";" Me.lstResults.RowSource = SQL Me.lstResults.Requery End Sub
Et mon problème est que mon tableau ne me renvoi aucun enregistrement ...
Quelqu'un saurait-il me dire d'où ça peut venir ???
Merci à ceux qui me consacreront un peu de leur temps.
@+ Vapo
Partager