First Names

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.
 
D

Douglas J. Steele

One approach would be

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

Beetle

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)
 
P

Philip Herlihy

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Mailing Address 3
Mailing address 1
Mailing Address 5
Grouping Names in Mail Merge 0
Cumulative formula for word table 0
Extracting specific words from a document 12
Breaking out data 3
IIF Function 2

Top