There are a few things you need to do to do this.
First, modify your report so that the Report Source is a query that selects only distinct fields, and does not include the Firstname field. It should look something like:
SELECT DISTINCT Surname, Address, Phone
FROM tblAddressBook
ORDER BY Surname, Address;
This will return only one record per unique Surname/Address combination.
Next, you need to add some VBA code to the Detail section:
* Right click in the Detail section and select Build Event...
* then select Code Builder
* Paste this code (exclduing the first and last lines, which should already be there)
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim db As Database
Dim rst As Recordset
Dim sSql As String
Dim sFirstName As String
'--select all the first names from records that match the current Surname and Address
sSql = "Select Firstname from tblAddressBook Where Surname = '" & tbxSurname & _
"' and Address ='" & tbxAddress & "' Order By FirstName"
Set db = CurrentDb
Set rst = db.OpenRecordset(sSql)
'--loop through all the records and add to a string
Do Until rst.EOF
sFirstName = sFirstName & rst!FirstName & ", "
rst.MoveNext
Loop
'--remove the trailing comma and space, and add to the text box
If Len(sFirstName) > 0 Then
tbxFirstName = Left$(sFirstName, Len(sFirstName) - 2)
End If
rst.Close
Set rst = Nothing
Set db = Nothing
End Sub
You will probably have to modify the table name and field names to match yours. Also, this code references some text boxes on the report, described below. Those names might need to be changed as well.
more to follow....