Solved

Dynamic Image won't display if no data is returned

Posted on 2016-09-01
11
88 Views
Last Modified: 2016-09-06
Crystal Reports XI
MS SQL 14

Thanks to everyone's help I have the dynamic images displaying properly.   I'm trying to make the reports look more polished if the search fails to return data.  I have encountered and old issue from the past where no data is returned from a query the Image will not display.   This also affected a formula that I used to display department name and address information in the header.

To inform the user I already know how to display an information message if no data is returned.
0
Comment
Question by:MikeM670
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
  • +1
11 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 41781076
You could put a message in a textbox in the report header.  Suppress it conditionally with a formula like
Count({SomeField}) > 0

Open in new window


Another way would be to create a formula and put it in the report header like
If Count({SomeField}) > 0 then
    "There is no data for the selected filtering"

Open in new window


mlmcc
0
 

Author Comment

by:MikeM670
ID: 41781902
I tried the textbox message suggestion and it will display a "No Data Message" if no data is returned but the image and formula to display the department name and address do not display?  Do I need to set something for the dynamic image or the formula?


Mike
0
 
LVL 35

Expert Comment

by:James0628
ID: 41782104
Where are the image and formula located?  Which section(s)?  You mentioned a header, but is that for the group, page or report?

 What's in the formula?

 James
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:MikeM670
ID: 41782153
The image and formula are both located in the Report Header.  

The formula for displaying the department info is:

local stringvar Line1;
local stringvar Line2;
local stringvar Line3;
local stringvar Line4;

if not(isnull({Agency.DepartmentTitle})) and trim({Agency.DepartmentTitle}) <> ""
then Line1 := {Agency.DepartmentTitle};

if not(isnull({Agency.StreetNumber})) and trim({Agency.StreetNumber}) <> ""
then Line2 := {Agency.StreetNumber} & " ";

if not(isnull({Agency.StreetPrefix})) and trim({Agency.StreetPrefix}) <> ""
then Line2 := Line2 & {Agency.StreetPrefix } & " ";

if not(isnull({Agency.Street})) and trim({Agency.Street}) <> ""
then Line2 := Line2 & {Agency.Street} & " ";

if not(isnull({Agency.StreetSuffix})) and trim({Agency.StreetSuffix}) <> ""
then Line2 := Line2 & {Agency.StreetSuffix} & " ";

if not(isnull({Agency.City})) and trim({Agency.City}) <> ""
then Line3 := {Agency.City} & " ";

if not(isnull({Agency.State})) and trim({Agency.State}) <> ""
then Line3 := Line3 & {Agency.State} & " ";

if not(isnull({Agency.Zip})) and trim({Agency.Zip}) <> ""
then Line3 := Line3 & {Agency.Zip} & " ";

if not(isnull({Agency.Phone})) and trim({Agency.Phone}) <> ""
then Line4 := "Telephone: " & {Agency.Phone} & " ";

if not(isnull({Agency.Fax})) and trim({Agency.Fax}) <> ""
then Line4 := Line4 & ' * ' & "Fax: " & {Agency.Fax} & " ";


Line1 & chr(13) & Line2 & chr(13) & Line3 & chr(13) & Line4;


For the dynamic image based on the parameter.

Format Editor\Picture\Graphic Location: is the following formula

if {CaseMaster.Agency} = {?Agency} then
    {Agency.ReportImageURL}
else
    '\\PSIMS\PSIMSReportImages\DefaultBlank.png'



Mike
0
 
LVL 35

Expert Comment

by:James0628
ID: 41782181
What is the formula supposed to produce if there is no data?  DepartmentTitle, etc. will all be null/blank, right?  If so, there's nothing to show.

 Same thing for the image.  CaseMaster.Agency will presumably be null/blank.  If you just want DefaultBlank.png to show up and it's not, you may just need to add an IsNull test on CaseMaster.Agency .

 James
0
 

Author Comment

by:MikeM670
ID: 41782193
Maybe I'm not explaining myself properly or not understanding what your saying.  There will always be at least one agency in the database with information and a related logo.    I want the Image and formula to always display the Image and department information even if the Report Selection Query fails to return any data.
0
 
LVL 23

Expert Comment

by:Ido Millet
ID: 41782200
Use IF THEN Else to check for IsNull and return the static path to the default department logo if the data is NULL.
0
 
LVL 35

Accepted Solution

by:
James0628 earned 500 total points
ID: 41782304
You say that there's always an agency in the db, but if you only have one query in the report and the record selection formula does not match any records, then the report will not include any of the data from that query, including the agency data.  All of the fields will be null.

 If that's the problem, the simplest solution might be to put the image and address formula in a subreport.  The subreport would read only the required agency data, and produce the corresponding image and address.

 James
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 41782533
Is the report based on tables joined in Crystal or is it a view or command?

mlmcc
0
 

Author Comment

by:MikeM670
ID: 41787206
The report is based on tables joined in crystal.
0
 

Author Closing Comment

by:MikeM670
ID: 41787210
I used the sub report method.  I would of preferred not having to do it that way as I needed to use two sub reports.  One for the logo image and one for the formula.  I had to do it that way in order to make room for other formulas and the report title to be shown below the department display formula.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question