SQL:
TRANSFORM Max([Result].[resResulttxt]) AS MaxOfresResulttxt
SELECT [Result].[resInfoID], [Test].[tstDesc] AS Analysis, [Result].[resMethod] AS Method, [Result].[resUnit] AS Unit
FROM Result INNER JOIN Test ON [Result].[resTestID]=[Test].[tstID]
GROUP BY [Result].[resInfoID], [Test].[tstDesc], [Result].[resMethod], [Result].[resUnit], Left([resSampleID],InStr([resSampleID],"/")-1)
PIVOT [resSiteDesc] & " " & [resSampleID];
I got it. I added the resinfoID field to the report and made it invisible (that's the one I tried to link). In the onopen sub I hide that column and set the report to filter it with a field from the main report. I hope this makes sense, but the trick is to get the subreport filter working.
Your questions:
To set up the link I used the subreport properties link dialogue where both fields came up. I couldn't use any column headings as they are dynamic.
Thanks for your trouble.
here's some of the code to set up the report:
<code>
For i = 0 To rst.Fields.Count - 1
If rst.Fields(i).Name <> "resInfoID" Then
Me.Detail.Controls(i - 1).Visible = True
Me.Detail.Controls(i - 1).ControlSource = rst.Fields(i).Name
If i > 3 Then
Me.ReportHeader.Controls(i - 1).Caption = rst.Fields(i).Name
Me.ReportHeader.Controls(i - 1).Visible = True
End If
End If
Next i
</code>
The i-1 hides the resInfoID column. A bit tacky but it works.
Bruce