If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
First Names
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. |
#2
|
|||
|
|||
First Names
One approach would be
=Trim([Titles] & " " & IIf(InStr([Firstname], " ") = 0, [Firstname], Left([Firstname], InStr([[Firstname], " ") - 1)) & " " & [Lastname]) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no private e-mails, please) "Roger Bell" wrote in message ... 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. |
#3
|
|||
|
|||
First Names
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) -- _________ Sean Bailey "Roger Bell" wrote: 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. |
#4
|
|||
|
|||
First Names
Douglas J. Steele wrote:
One approach would be =Trim([Titles] & " " & IIf(InStr([Firstname], " ") = 0, [Firstname], Left([Firstname], InStr([[Firstname], " ") - 1)) & " " & [Lastname]) "Roger Bell" wrote in message ... 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 |
Thread Tools | |
Display Modes | |
|
|