Last Name First
In our application, some reports needed the name broken in component parts and others strung together. A number of Functions gave us what was needed each time.
Public Function LastNameFirst(sID As Long) As String
Dim theName As String
Dim Borrows As Recordset
Set Borrows = CurrentDb.OpenRecordset("BorrowerInfo", dbOpenDynaset, dbSeeChanges)
Do Until Borrows.EOF
With Borrows
If !DVid = sID Then
theName = !LastName
If Len(!Prefix) > 0 Then
theName = theName & ", " & !Prefix & Chr(32) & !FirstNameMI & Chr(32) & !Suffix
Else
theName = theName & ", " & !FirstNameMI & Chr(32) & !Suffix
End If
Exit Do
End If
End With
Borrows.MoveNext
Loop
LastNameFirst = theName
Borrows.Close
End Function
Using a RecordSet gave us a signficant time advantage over a bunch of DLookUps.
|