Compare 2 text fields and leave one field null if it has the same data as the first field

B

Barbara Brenner

I'm working with a train station index. Here's what I need to do--if the
OrigStation has the same text as the SwitchStation, the text should be
removed from the SwitchStation field so that only stations which use a
Switch Station belonging to someone else should show. In the example, both
the Aberdeen and the Buffalo Barn stations have the same SwitchStation name,
so the SwitchStation column should be blank in those 2 cases. Hope I
explained this okay.

Like this:

OrigStation SwitchStation
Aberdeen
Belt Jct. Mobile, AL
Buffalo Barn, AL
 
G

Gary Wheeler

Use an update query and in the update to section use an
IIF statement.

For Example:

IIF([OrigStation]=[SwitchStation],NULL,[SwitchStation])

In place of NULL you could use "" but you need to make
sure that in the SwitchStation Field
Allow Zero Length is set to Yes.

GAry
 
B

Barbara Brenner

Thank you! Worked just fine.

Gary Wheeler said:
Use an update query and in the update to section use an
IIF statement.

For Example:

IIF([OrigStation]=[SwitchStation],NULL,[SwitchStation])

In place of NULL you could use "" but you need to make
sure that in the SwitchStation Field
Allow Zero Length is set to Yes.

GAry
-----Original Message-----
I'm working with a train station index. Here's what I need to do--if the
OrigStation has the same text as the SwitchStation, the text should be
removed from the SwitchStation field so that only stations which use a
Switch Station belonging to someone else should show. In the example, both
the Aberdeen and the Buffalo Barn stations have the same SwitchStation name,
so the SwitchStation column should be blank in those 2 cases. Hope I
explained this okay.

Like this:

OrigStation SwitchStation
Aberdeen
Belt Jct. Mobile, AL
Buffalo Barn, AL


.
 

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