-----Original Message-----
You can use the following function in a query that contains only one record
per student. Copy the function into a new module and save it as
"basConcatenate". There is sample usage provided in the code comments.
Function Concatenate(pstrSQL As String, _
Optional pstrDelim As String = ", ") _
As String
'example
'tblFamily with FamID as numeric primary key
'tblFamMem with FamID, FirstName, DOB,...
'return a comma separated list of FirstNames
'for a FamID
' John, Mary, Susan
'in a Query
'SELECT FamID,
'Concatenate("SELECT FirstName FROM tblFamMem
' WHERE FamID =" & [FamID]) as FirstNames
'FROM tblFamily
'
'======For DAO uncomment next 4 lines=======
'====== comment out ADO below =======
'Dim db As DAO.Database
'Dim rs As DAO.Recordset
'Set db = CurrentDb
'Set rs = db.OpenRecordset(pstrSQL)
'======For ADO uncomment next two lines=====
'====== comment out DAO above ======
Dim rs As New ADODB.Recordset
rs.Open pstrSQL, CurrentProject.Connection, _
adOpenKeyset, adLockOptimistic
Dim strConcat As String 'build return string
With rs
If Not .EOF Then
.MoveFirst
Do While Not .EOF
strConcat = strConcat & _
.Fields(0) & pstrDelim
.MoveNext
Loop
End If
.Close
End With
Set rs = Nothing
'====== uncomment next line for DAO ========
'Set db = Nothing
If Len(strConcat) > 0 Then
strConcat = Left(strConcat, _
Len(strConcat) - Len(pstrDelim))
End If
Concatenate = strConcat
End Function
--
Duane Hookom
MS Access MVP
Mario said:
Lets say I have a table like this:
StudentName |Evaluator |Comments
-----------------------------------------
David |Mary |Need Improvment
David |Mitchell |Good
David |Marco |Reading needs attention
Jeena |Stefany |Excellent
Can somebody help me with a querry syntax that can
produced the following results;
StudentName |Evaluators_Comments
------------------------------------
David |Needs Improvement, Good Reading, needs
attention
Jeena |Excellent
Please help.
.