Need help with an "if" sql statement

H

hansjhamm

I do not know even how to approach this one, so help will be GREATLY
appreciated.

The line I currently use is:

DoCmd. RunSQL"update CAEmployees set[Name]=[NickName]&' '&[LastName]"

To create a new field in my table. But, in some cases the real name of
the person is used and not the nickname. So, I would need something
like this

If NickName is "" then FirstName&' '& LastName else NickName&'
"&LastName

How would I go about writing this within this line?

Thanks,


Hans
 
L

Lynn Trapp

Give this a try:

DoCmd. RunSQL"update CAEmployees
set[Name]=IIF(IsNull([NickName]),[FirstName],[NickName])&' '&[LastName]"
 
H

hansjhamm

Lynn,

Worked like a CHARM!!!


Thanks,

Hans

Lynn said:
Give this a try:

DoCmd. RunSQL"update CAEmployees
set[Name]=IIF(IsNull([NickName]),[FirstName],[NickName])&' '&[LastName]"


--

Lynn Trapp
Microsoft MVP (Access)
www.ltcomputerdesigns.com


I do not know even how to approach this one, so help will be GREATLY
appreciated.

The line I currently use is:

DoCmd. RunSQL"update CAEmployees set[Name]=[NickName]&' '&[LastName]"

To create a new field in my table. But, in some cases the real name of
the person is used and not the nickname. So, I would need something
like this

If NickName is "" then FirstName&' '& LastName else NickName&'
"&LastName

How would I go about writing this within this line?

Thanks,


Hans
 
L

Lynn Trapp

That's great!

--

Lynn Trapp
Microsoft MVP (Access)
www.ltcomputerdesigns.com


Lynn,

Worked like a CHARM!!!


Thanks,

Hans

Lynn said:
Give this a try:

DoCmd. RunSQL"update CAEmployees
set[Name]=IIF(IsNull([NickName]),[FirstName],[NickName])&' '&[LastName]"


--

Lynn Trapp
Microsoft MVP (Access)
www.ltcomputerdesigns.com


I do not know even how to approach this one, so help will be GREATLY
appreciated.

The line I currently use is:

DoCmd. RunSQL"update CAEmployees set[Name]=[NickName]&' '&[LastName]"

To create a new field in my table. But, in some cases the real name of
the person is used and not the nickname. So, I would need something
like this

If NickName is "" then FirstName&' '& LastName else NickName&'
"&LastName

How would I go about writing this within this line?

Thanks,


Hans
 

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