Concatenation operator &

M

musicman509

how do i add a dash between each string and if there is no string2 not have
the dash appear
 
D

Douglas J. Steele

Assuming that string2 is Null, and not just an empty string (""), you can
take advantage of the fact that + works differently with concatenation than
&:

string1 & ("-" + string2)

If it's not null (or if it's sometimes Null but sometimes not), you'll need
something like

string1 & IIf(Len(string2 & "") > 0, "-" & string2, "")
 
Top