I want to add these two strings to this string so as they are on the last 2
lines, Thanks for any help.....Bob
NameAddress: IIf(IsNull(tblOwnerInfo.OwnerTitle),'',tblOwnerInfo.OwnerTitle
& ' ') &
IIf(IsNull(tblOwnerInfo.OwnerFirstName),'',tblOwnerInfo.OwnerFirstName & '
') & IIf(IsNull(tblOwnerInfo.OwnerLastName),'',tblOwnerInfo.OwnerLastName) &
Chr(13) & Chr(10) &
IIf(IsNull(tblOwnerInfo.OwnerAddress),'',Replace(tblOwnerInfo.OwnerAddress,Chr(13)
& Chr(10)," "))
& IIf(IsNull(tblOwnerInfo.GSTRacingNumber,Chr(13) & Chr(10)," "))
& IIf(IsNull(tblOwnerInfo.GSTRacingYesNo,Chr(13) & Chr(10)," "))
Graham Mandeno - 19 Jun 2007 03:23 GMT
Hi Bob
There's a very useful trick you can use here. In many ways the + and &
operators behave the same way with strings, but not where one or the
operands in Null.
These give the same result:
"String1" & "String2" = "String1String2"
and
"String1" + "String2" = "String1String2"
But:
"String1" & Null = "String1"
and
"String1" + Null = Null
So, you can wrap the component fields that might be Null, along with the
bits that go with them, in parentheses using +, and join them all together
using &. This way, nearly all your "IIf"s can disappear:
NameAddress: (OwnerTitle + ' ') & (OwnerFirstName + ' ') & OwnerLastName
& IIf(IsNull(OwnerAddress),'',
Chr(13) & Chr(10) & Replace(OwnerAddress,Chr(13) & Chr(10)," "))
& (Chr(13) + Chr(10) + GSTRacingNumber) & (Chr(13) + Chr(10) +
GSTRacingYesNo)
Note that the IIf for OwnerAddress is still required because Replace will
return an empty string, not a Null, if you pass it a Null.

Signature
Good Luck :-)
Graham Mandeno [Access MVP]
Auckland, New Zealand
> I want to add these two strings to this string so as they are on the last
> 2 lines, Thanks for any help.....Bob
[quoted text clipped - 10 lines]
>
> & IIf(IsNull(tblOwnerInfo.GSTRacingYesNo,Chr(13) & Chr(10)," "))
Bob V - 19 Jun 2007 23:08 GMT
Thanks graham, wish training race horses was that easy....Regards Bob Vance
> Hi Bob
>
[quoted text clipped - 40 lines]
>>
>> & IIf(IsNull(tblOwnerInfo.GSTRacingYesNo,Chr(13) & Chr(10)," "))