View Full Version : Concatenating issue with a twist. . .


WebFaktor
03-05-2002, 12:11 PM
I'm having trouble stopping concatenation when/if a field becomes empty, thus preventing multiple greater than symbols ">" from appearing. I use the greater than symbol ">" to separate each field as it appears once concatenated. In the sample below, of the 3 "Directions"-fields only 1 contained an entry, thus the entry is followed by 2 greater than signs. Can I stop the concatenation from proceeding if a field is empty - thus preventing multiple greater than symbols from appearing?

Thanks in advance,

Michael

CODE:
Expr1: [Directions_1] & " > " & [Directions_2] & " > " & [Directions_3]

RESULT:
Go to A > >

David R
03-05-2002, 12:22 PM
Use IIF statements is probably your best bet if you're going to build these in the query itself. Otherwise with code you can use If...Then.

HTH,
David R

WebFaktor
03-05-2002, 12:29 PM
David,

Sorry to trouble you further, but would you mind providing me a sample of how I would achieve what you suggest - I'm a little new to this.

Thanks!

Michael

David R
03-05-2002, 01:17 PM
Something along the lines of this should work:
Expr1: [Directions_1] & IIf([Directions_1],IIf([Directions_2]," > ")) & [Directions_2] & IIf([Directions_1] Or [Directions_2],IIf([Directions_3]," > ")) & [Directions_3]

Now, the larger question becomes: Do you have a valid reason to have three columns of apparently similar purpose? Would this be better served with a one-to-many relationship between two tables? If you don't understand what I mean, look up 'database normalization' and check back here if you have further questions.

Good luck,
David R

WebFaktor
03-05-2002, 01:33 PM
Thank you, David for your assistance with this. The code you sent worked perfectly for my circumstance.

Michael