Skip to main content
Inspiring
August 28, 2008
Answered

Problem with IIf in Report Builder

  • August 28, 2008
  • 1 reply
  • 1741 views
Hi,

This is my first try with Report Builder and I have managed to create some custom labels however I would like to hide any empty address fields. At the moment if any of the address fields are empty I get an empty line terminated by the comma that I have added to each line. Here is my label expression:

query.Title & " " & query.Initials & " " & query.Surname & Chr(13) & Chr(10) &
Trim(query.Address1) & "," & Chr(13) & Chr(10) &
IIf(Trim(query.Address2) is '',DE(""),DE(Trim(query.Address2) & "," & Chr(13) & Chr(10) &)
Trim(query.Address3) & "," & Chr(13) & Chr(10) & Trim(query.Town) & "," & Chr(13) & Chr(10) &
Trim(query.County) & "," & Chr(13) & Chr(10) &
Trim(query.PostCode)

This is line causing problems:

IIf(Trim(query.Address2) is '',DE(""),DE(Trim(query.Address2) & "," & Chr(13) & Chr(10) &)

In expression builder how can I get this to work? I have tried various combinations of quotes and # symbols, with and without using DE() but they all throw the same error:

"...is not a valid ColdFusion expression"

I am sure it something simple I am missing.

Cheers,

Dave
This topic has been closed for replies.
Correct answer cpeterson
This is how I was able to get it to work correctly on mine:

IIf(query.Address2 NEQ '', DE(query.Address2 & Chr(13) & Chr(10)), DE(query.Address2))

Even though Address 2 is blank, it doesn't seem to like DE("").

1 reply

cpetersonCorrect answer
Participant
September 17, 2008
This is how I was able to get it to work correctly on mine:

IIf(query.Address2 NEQ '', DE(query.Address2 & Chr(13) & Chr(10)), DE(query.Address2))

Even though Address 2 is blank, it doesn't seem to like DE("").
Inspiring
September 17, 2008
Worked perfectly - thanks very much for posting the solution.