Report recordsource:
SELECT DISTINCTROW Classes.*, Students.*, Assignments.*, Results.*,
[LastName] & ", " & [FirstName] AS [Student Name] FROM (Students INNER
JOIN
((Classes INNER JOIN [Students And Classes] ON Classes.ClassID=[Students
And
Classes].ClassID) INNER JOIN Assignments ON
Classes.ClassID=Assignments.ClassID) ON Students.StudentID=[Students And
Classes].StudentID) INNER JOIN Results ON
(Students.StudentID=Results.StudentID) AND
(Assignments.AssignmentID=Results.AssignmentID);
On Format of the CLASSID Group footer:
=FillTextBox() 'This function fills in the txtNYC textbox
'************************************
Function FillTextBox()
Dim rstMyRecords As Recordset
Dim strSQL As String
Dim strNYC As String
strSQL = "SELECT DISTINCTROW Students.StudentID, Classes.ClassID,
Results.Verification, Assignments.PerformanceID FROM (Students INNER JOIN
((Classes INNER JOIN [Students And Classes] ON Classes.ClassID=[Students
And
Classes].ClassID) INNER JOIN Assignments ON
Classes.ClassID=Assignments.ClassID) ON Students.StudentID=[Students And
Classes].StudentID) INNER JOIN Results ON
(Assignments.AssignmentID=Results.AssignmentID) AND
(Students.StudentID=Results.StudentID)WHERE (((Students.StudentID)=1) AND
((Classes.ClassID)=1) AND ((Results.Verification)=No));"
rstMyRecords.MoveFirst
Do While rstMyRecords.EOF = False
strNYC = strNYC & rstMyRecords(3) & ", "
rstMyRecords.MoveNext
Loop
Reports![A4 Results].txtNYC = strNYC
End Function
My filled textbox contains, or should contain the results written to an
array. This is each of the competency performance ID not checked.
Surely there must be a way to pass the current StudentID and ClassID from
the Report recordsource SQL to the SQL in the Function FillTextBox().
Any clues.
Duane Hookom said:
If you need to return only a single record, DLookup() might be an
alternative.
--
Duane Hookom
MS Access MVP
I call a function that runs an sql and fills the text box with the
result.
I
was hoping I could link this query with the report recordsource and
the
current record.
As you suggest I may have to open a sub report.
Thanks
:
How do you "run another SQL query"? I would expect you to design a
subreport
to return the values you want to display. Use this subreport with
Link
Master/Child to your StudentID and ClassID.
--
Duane Hookom
MS Access MVP
I wonder if you can help me with a particular reporting problem.
My report uses an SQL recordsource, and I group and sort on
StudentID
and
ClassID and Assignments.
I run another SQL query which populates a text box which resides
in the
ClassID group footer. This query lists all of the assignments not
yet
marked
as verfified (check box). This all works fine except the query
does not
filter the StudentID and ClassID so all records are returned into
the
text
box.
Is there a way in which I can pass the grouped current record
StudentID
and
ClassID from the Report Recordsource into the query in the group
footer
for
ClassID.
Thanks for any help.
Cheers