First Names

  • Thread starter Thread starter Roger Bell
  • Start date Start date
R

Roger Bell

I have a text box on a report as follows:
=Trim([Titles] & " " & [Firstname] & " " & [Lastname])
The problem is that sometimes the Firstname field contains more than 1 name.
eg: John William
I would like to incorporate a function in the command above that will show
only the first name reference.
eg: John
Could someone please advise how I can do this?
Many thanks for your help.
 
One approach would be

=Trim([Titles] & " " & IIf(InStr([Firstname], " ") = 0, [Firstname],
Left([Firstname], InStr([[Firstname], " ") - 1)) & " " & [Lastname])
 
Assuming that there is always just a single space between
the two parts of the first name;

=Trim([Title] & " " & IIf(InStr([FirstName]," ")>0,
Left([FirstName],InStr([FirstName]," ")-1),[FirstName])
& " " & [LastName])

(You'll have to correct for line wrap)
 
Douglas said:
One approach would be

=Trim([Titles] & " " & IIf(InStr([Firstname], " ") = 0, [Firstname],
Left([Firstname], InStr([[Firstname], " ") - 1)) & " " & [Lastname])


Roger Bell said:
I have a text box on a report as follows:
=Trim([Titles] & " " & [Firstname] & " " & [Lastname])
The problem is that sometimes the Firstname field contains more than 1
name.
eg: John William
I would like to incorporate a function in the command above that will show
only the first name reference.
eg: John
Could someone please advise how I can do this?
Many thanks for your help.


Like addresses, names just aren't "regular" enough! In this sort of
situation I've sometimes concluded that it's worth storing an extra
field "display name" and using that where appropriate.

Phil, London
 
Back
Top