Handling literals in labels using TRIM

D

Dan

I'd like my labels to print either:
Firstname & Spousename and lastname (with the & char).
Or, if there is no spousename, I'd like the label to print firstname and
lastname only.
I'm having a problem writing the TRIM to not print the & char if there is no
spousename.
Thanks for any suggestions..
Dan
 
A

Al Camp

Dan
Create a calculated field named [FullName] for exampole and set the Control Source
to...
= FirstName & IIF(IsNull(SpouseName)," ", " & " & SpouseName & " ") & LastName
Didn't test, but should be OK...
 
B

BruceM

As a slight variant:

=[FirstName] & (" & " + [SpouseName]) & " " & [LastName]

By using the plus sign, if any part of the expression within the parentheses
evaluates to null the entire expression within the parentheses evaluates to
null. It doesn't make a huge difference here, but it is a handy technique
to know.
Do spouses ever have different last names?

Al Camp said:
Dan
Create a calculated field named [FullName] for exampole and set the
Control Source to...
= FirstName & IIF(IsNull(SpouseName)," ", " & " & SpouseName & " ") &
LastName
Didn't test, but should be OK...
--
hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions

Dan said:
I'd like my labels to print either:
Firstname & Spousename and lastname (with the & char).
Or, if there is no spousename, I'd like the label to print firstname and
lastname only.
I'm having a problem writing the TRIM to not print the & char if there is
no
spousename.
Thanks for any suggestions..
Dan
 
D

Dan

thanks all. Just what I needed. No, all have the same last name (as of now!)


BruceM said:
As a slight variant:

=[FirstName] & (" & " + [SpouseName]) & " " & [LastName]

By using the plus sign, if any part of the expression within the parentheses
evaluates to null the entire expression within the parentheses evaluates to
null. It doesn't make a huge difference here, but it is a handy technique
to know.
Do spouses ever have different last names?

Al Camp said:
Dan
Create a calculated field named [FullName] for exampole and set the
Control Source to...
= FirstName & IIF(IsNull(SpouseName)," ", " & " & SpouseName & " ") &
LastName
Didn't test, but should be OK...
--
hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions

Dan said:
I'd like my labels to print either:
Firstname & Spousename and lastname (with the & char).
Or, if there is no spousename, I'd like the label to print firstname and
lastname only.
I'm having a problem writing the TRIM to not print the & char if there is
no
spousename.
Thanks for any suggestions..
Dan
 
B

BruceM

You may want to give some thought now to how you will handle that last name
situation. One way is to have an alternate SpouseLast field. If the field
is null, concatenate the expression as has been suggested, otherwise (i.e.
if it is not null) concatenate it differently.

Dan said:
thanks all. Just what I needed. No, all have the same last name (as of
now!)


BruceM said:
As a slight variant:

=[FirstName] & (" & " + [SpouseName]) & " " & [LastName]

By using the plus sign, if any part of the expression within the
parentheses
evaluates to null the entire expression within the parentheses evaluates
to
null. It doesn't make a huge difference here, but it is a handy
technique
to know.
Do spouses ever have different last names?

Al Camp said:
Dan
Create a calculated field named [FullName] for exampole and set the
Control Source to...
= FirstName & IIF(IsNull(SpouseName)," ", " & " & SpouseName & " ") &
LastName
Didn't test, but should be OK...
--
hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions

I'd like my labels to print either:
Firstname & Spousename and lastname (with the & char).
Or, if there is no spousename, I'd like the label to print firstname
and
lastname only.
I'm having a problem writing the TRIM to not print the & char if there
is
no
spousename.
Thanks for any suggestions..
Dan
 
D

Dan

Bruce:
Great suggestion. I haven't run across that situation yet so I'll
incorporate it before the occasion pops up.
Dan

BruceM said:
You may want to give some thought now to how you will handle that last name
situation. One way is to have an alternate SpouseLast field. If the field
is null, concatenate the expression as has been suggested, otherwise (i.e.
if it is not null) concatenate it differently.

Dan said:
thanks all. Just what I needed. No, all have the same last name (as of
now!)


BruceM said:
As a slight variant:

=[FirstName] & (" & " + [SpouseName]) & " " & [LastName]

By using the plus sign, if any part of the expression within the
parentheses
evaluates to null the entire expression within the parentheses evaluates
to
null. It doesn't make a huge difference here, but it is a handy
technique
to know.
Do spouses ever have different last names?

Dan
Create a calculated field named [FullName] for exampole and set the
Control Source to...
= FirstName & IIF(IsNull(SpouseName)," ", " & " & SpouseName & " ") &
LastName
Didn't test, but should be OK...
--
hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions

I'd like my labels to print either:
Firstname & Spousename and lastname (with the & char).
Or, if there is no spousename, I'd like the label to print firstname
and
lastname only.
I'm having a problem writing the TRIM to not print the & char if there
is
no
spousename.
Thanks for any suggestions..
Dan
 

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

Top