Concatenating multiple name fields to produce greetings

G

Guest

I'm volunteering for a nonprofit. They want to do this.
Got a db with the following fields:
Fname Lname SpouseFname SpouseLname
I want to create a query that returns the follow: If the SpouseLname =
LName Then create a new field called GreetingName that is Fname & (the actual
symbol) SpouseFname Lname

So Foo Smith and Foolet Smith become Foo & Foolet Smith in the final query
result.

Anyone know the right way to structure this query? Using Access 2003, XP Pro
SP2
 
J

Jeff Boyce

Not a query even! Just a new field in an existing query. You could use
something like:

GreetingName: IIF([SpouseLName]=[LName],[FName] & " & " & [SpouseFName]
& " " & [LName], ...)

Now, YOU get to fill in the part with "...", which is where you put what you
want to see if the spouse's lastname is not the same as the lastname.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
G

Guest

Thanks very much Jeff. You rock. I figured it was simple, but my lack of
daily familiarity with Access was slowing this simple task down.



Jeff Boyce said:
Not a query even! Just a new field in an existing query. You could use
something like:

GreetingName: IIF([SpouseLName]=[LName],[FName] & " & " & [SpouseFName]
& " " & [LName], ...)

Now, YOU get to fill in the part with "...", which is where you put what you
want to see if the spouse's lastname is not the same as the lastname.

Regards

Jeff Boyce
Microsoft Office/Access MVP

Al in PT said:
I'm volunteering for a nonprofit. They want to do this.
Got a db with the following fields:
Fname Lname SpouseFname SpouseLname
I want to create a query that returns the follow: If the SpouseLname =
LName Then create a new field called GreetingName that is Fname & (the
actual
symbol) SpouseFname Lname

So Foo Smith and Foolet Smith become Foo & Foolet Smith in the final query
result.

Anyone know the right way to structure this query? Using Access 2003, XP
Pro
SP2
 
G

Guest

Here's what I came up with: This query will return a field that parses First
Names, Last Names, Spouse First Names, Spouse Last Names, and handle blank
fields (those without spouselnames in them) to make a greeting field for
mailings or newsletters. Would there have been an easier way to do this?
Would love to know.

GreetingName: IIf([spouselname]=[last],[first] & " & " & [spousefname] & "
" & [last],IIf([spouselname]<>[last],[first] & " " & [last] & " &" & " " &
[spousefname] & " " & [spouselname],IIf(IsNull([spousefname]),[first] & " "
& [last],IIf(IsNull([spouselname]) And ([spousefname]),[first] & " &" & " "
& [spousefname] & " " & [last]))))


Jeff Boyce said:
Not a query even! Just a new field in an existing query. You could use
something like:

GreetingName: IIF([SpouseLName]=[LName],[FName] & " & " & [SpouseFName]
& " " & [LName], ...)

Now, YOU get to fill in the part with "...", which is where you put what you
want to see if the spouse's lastname is not the same as the lastname.

Regards

Jeff Boyce
Microsoft Office/Access MVP

Al in PT said:
I'm volunteering for a nonprofit. They want to do this.
Got a db with the following fields:
Fname Lname SpouseFname SpouseLname
I want to create a query that returns the follow: If the SpouseLname =
LName Then create a new field called GreetingName that is Fname & (the
actual
symbol) SpouseFname Lname

So Foo Smith and Foolet Smith become Foo & Foolet Smith in the final query
result.

Anyone know the right way to structure this query? Using Access 2003, XP
Pro
SP2
 
J

Jeff Boyce

Thanks for posting your complete solution. Someone else somewhere, sometime
will be looking for an answer and will find yours!

Regards

Jeff Boyce
Microsoft Office/Access MVP

Al in PT said:
Here's what I came up with: This query will return a field that parses
First
Names, Last Names, Spouse First Names, Spouse Last Names, and handle blank
fields (those without spouselnames in them) to make a greeting field for
mailings or newsletters. Would there have been an easier way to do this?
Would love to know.

GreetingName: IIf([spouselname]=[last],[first] & " & " & [spousefname] &
"
" & [last],IIf([spouselname]<>[last],[first] & " " & [last] & " &" & " "
&
[spousefname] & " " & [spouselname],IIf(IsNull([spousefname]),[first] & "
"
& [last],IIf(IsNull([spouselname]) And ([spousefname]),[first] & " &" & "
"
& [spousefname] & " " & [last]))))


Jeff Boyce said:
Not a query even! Just a new field in an existing query. You could use
something like:

GreetingName: IIF([SpouseLName]=[LName],[FName] & " & " &
[SpouseFName]
& " " & [LName], ...)

Now, YOU get to fill in the part with "...", which is where you put what
you
want to see if the spouse's lastname is not the same as the lastname.

Regards

Jeff Boyce
Microsoft Office/Access MVP

Al in PT said:
I'm volunteering for a nonprofit. They want to do this.
Got a db with the following fields:
Fname Lname SpouseFname SpouseLname
I want to create a query that returns the follow: If the SpouseLname =
LName Then create a new field called GreetingName that is Fname & (the
actual
symbol) SpouseFname Lname

So Foo Smith and Foolet Smith become Foo & Foolet Smith in the final
query
result.

Anyone know the right way to structure this query? Using Access 2003,
XP
Pro
SP2
 

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