I found some code on google.
Function SelectedRecords()
Dim i As Long
Dim F As Form
Dim RS As Recordset
' Get the form and its recordset.
Set F = Forms![Location_Z_Detailed_frm]
Set RS = F.RecordsetClone
' Move to the first record in the recordset.
RS.MoveFirst
' Move to the first selected record.
RS.Move F.SelTop - 1
' Enumerate the list of selected records presenting
' the CompanyName field in a message box.
For i = 1 To F.SelHeight
'msgbox RS![Z_Site_Name]
RS.MoveNext
Next i
intSelectedRecords = i - 1
'Debug.Print i - 1
End Function