Basic IF statement question

  • Thread starter NeonSky via AccessMonster.com
  • Start date
N

NeonSky via AccessMonster.com

Hello All!

Hi, what I am trying to do sounds quite simple though I am not sure how to do
it. Here is the scenario: If field "A" is null and field "B" is not null then
populate field "A" with data from field "B" and then delete the contents of
field "A".

Your assistance is much appreciated!

Thank you!
 
J

Jeff Boyce

Does not compute!

You are taking data from field "B", putting it in "A", and deleting the data
from "A"?!

Take a look at an update query to accomplish this, and the IIF() function to
evaluate if "A" is null (?or a zero-length string?) and "B" is not.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
J

John Vinson

Hello All!

Hi, what I am trying to do sounds quite simple though I am not sure how to do
it. Here is the scenario: If field "A" is null and field "B" is not null then
populate field "A" with data from field "B" and then delete the contents of
field "A".

I'm confused.

It sounds like you want to fill field A and then empty it, thereby
doing nothing at all.

I could make a guess at what you MEANT to say... but I'd rather you
say it so there's a better chance of it matching what you actually
want!

John W. Vinson[MVP]
 
N

NeonSky via AccessMonster.com

You both are tottaly right, my mistake. I meant to say: If field "A" is null
and field "B" is not null then
populate field "A" with data from field "B" and then delete the contents of
field "B".

Thanks!!!
 
J

John Vinson

You both are tottaly right, my mistake. I meant to say: If field "A" is null
and field "B" is not null then
populate field "A" with data from field "B" and then delete the contents of
field "B".

Update queries happen "all at once", not procedurally in sequence - so
you can simply

UPDATE MyTable
SET [A] = ,
= NULL
WHERE [A] IS NULL
AND IS NOT NULL;


John W. Vinson[MVP]
 
N

NeonSky via AccessMonster.com

u rock.

John said:
You both are tottaly right, my mistake. I meant to say: If field "A" is null
and field "B" is not null then
populate field "A" with data from field "B" and then delete the contents of
field "B".

Update queries happen "all at once", not procedurally in sequence - so
you can simply

UPDATE MyTable
SET [A] = ,
= NULL
WHERE [A] IS NULL
AND IS NOT NULL;

John W. Vinson[MVP]
 
Top