Bonjour,
J’ai une fonction dans module et une requête afin d’obtenir tous les champs possibles pour un même champ
et ça fonctionne très bien.
Malheureusement ça fonctionne pas avec une requête de sélection !!!!
voici le module:
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
20
21
22
23
24 Public Function ConcatAnt(ByVal strDesignation As String) As String Dim db1 As DAO.Database, rs1 As DAO.Recordset Dim strSql As String, s1 As String Dim strQuery As String strQuery = "R_Avant_DFacts" Set db1 = CurrentDb strSql = "SELECT DISTINCT Ant FROM " & strQuery & " WHERE Designation ='" & strDesignation & "' ORDER BY Ant" Set rs1 = db1.OpenRecordset(strSql) If rs1.RecordCount = 0 Then GoTo Exit_0 rs1.MoveLast rs1.MoveFirst s1 = "" While Not rs1.EOF If Nz(rs1!Ant) <> "" Then s1 = s1 & Nz(rs1!Ant) & ", " End If rs1.MoveNext Wend Exit_0: ConcatAnt = s1 Exit Function End Function
la requête:
Code sql : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 SELECT R_Avant_DFacts.Designation, concatAnt([Designation]) AS Resultat FROM R_Avant_DFacts GROUP BY R_Avant_DFacts.Designation, concatAnt([Designation]);
la requête de sélection :
Code sql : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 SELECT T_Clients.NClient, T_Factures.NFacture, T_Clients.Nom, T_Factures.Date, T_Det_Facts.Designation, T_Det_Facts.Quantite, (" ( " & [Date] & " - " & [Quantite] & " ) ") AS Ant FROM T_Produits INNER JOIN ((T_Clients INNER JOIN T_Factures ON T_Clients.NClient = T_Factures.NumClient) INNER JOIN (T_Det_Facts INNER JOIN R_Prds_NFact ON T_Det_Facts.Designation = R_Prds_NFact.Designation) ON T_Factures.NFacture = T_Det_Facts.NumFact) ON T_Produits.Produit = T_Det_Facts.Designation WHERE (((T_Clients.NClient)=[Formulaires]![F_Clients]![T_Factures sous-formulaire].[Formulaire]![NumClient]) AND ((T_Factures.Date)<[Formulaires]![F_Clients]![T_Factures sous-formulaire].[Formulaire]![Date]));
Une solution?
merci
Partager