I\'m using MS-Access 2003 with the query creator. I select everything from one table (FaitsSaillants
), then one specific row (WHERE VARIABLE=\'TitreMandat\'
How about:
PARAMETERS [CurrAxe] TEXT ( 255 ), [CurrOTP] TEXT ( 255 ), [CurrClient] TEXT (
255 ), [StartDate] DATETIME, [EndDate] DATETIME;
SELECT q.Projet, *
FROM (faitssaillants f
LEFT JOIN employes e
ON f.utilisateur = e.cip)
INNER JOIN (
SELECT s1.otp,
[s1].[valeur] & "," & [s2].[valeur] AS Projet
FROM (
SELECT otp, valeur
FROM tb_sommaire
WHERE [variable] = 'TitreMandat') AS s1
INNER JOIN (
SELECT otp, valeur
FROM tb_sommaire
WHERE [variable] = 'NomInstallation') AS s2
ON s1.otp = s2.otp) q
ON f.otp = q.otp
WHERE f.otp = [currotp]
AND f.client LIKE [currclient]
AND f.axe LIKE [curraxe]
AND Datevalue([dateinsertion])
Between [startdate] And [enddate]
ORDER BY f.dateinsertion DESC;
It is always best to avoid referencing all fields as *. Fields (columns) should be listed by name.
The above depends on creating a derived table that groups rows from tb_sommaire by Otp. You can cut and paste the derived table into a query design screen (sql view) to check that the rows returned are as expected.