Solved

Changing Image in report header based on parameter value

Posted on 2016-08-26
12
41 Views
Last Modified: 2016-08-29
Using Crystal Reports IX
SQL 2014

I have developed reports where there is a department logo image currently embedded in each report header.  I would like to be able to dynamically change the department logo based on a value the user enters which corresponds to the AgencyID.   Currently I either completely remove the logo image or painstakingly replace the image with another for each department.  

All departments use a version of MS SQL Server.  Some locations there may only be "One" department in the database so the default agency value is "1".  Other locations there can be multiple departments with a corresponding AgencyID.  

Example:
Single Agency Database    
AgencyID
      1      

Multiple Agency Database
AgencyID
       1
       2
       3

Can I link to a specific image?    Example: \\Image\departmentlogo1.jpg

Or do I need to store the image into the database?
0
Comment
Question by:MikeM670
  • 5
  • 4
  • 2
  • +1
12 Comments
 
LVL 18

Assisted Solution

by:vasto
vasto earned 125 total points
Comment Utility
How many departments do you have ? If the number is small (2-4) you can add all images to the report and suppress all of them except the one for the current department. If you have more departments you can either load them dynamically using graphic location or pass them from the database. To set graphic location right click the image object and select menu "Format graphics", goto Picture tab ( the second one) and click the formula button for Graphic location, You can write a formula and return different path based on department ID
0
 

Author Comment

by:MikeM670
Comment Utility
Vasto,

The second option would  have to be the way.  Some database locations  have many departments and it would be impossible to add all those images.  And since the report would be used in departments that were added after the report was written it would be a nightmare to maintain.

Would you recommend using a image field in the database that correspond to the  agencyid or using a url path?
0
 
LVL 18

Expert Comment

by:vasto
Comment Utility
I would not recommend adding the image to the database. I know it is used widely , but it will require a BLOB field and I don't like BLOB fields. It is up to you though. The network traffic will be the same or similar. Database will give you a little bit more security, nobody will be able to change the logos without permissions, however managing the logos will be a little bit more complicate. I would place the logo in a network folder and use DepartmentID or name as a file name. The formula will just concatenate the folder name with the department id/name to return the right file.
0
 

Author Comment

by:MikeM670
Comment Utility
The simple option of adding the image to the database is probably the way I would go.  The logo's are not something that changes and I need to keep things simple and easy.  This is something that can be set and forget when the database is setup or a new agency is added to it.
0
 
LVL 100

Assisted Solution

by:mlmcc
mlmcc earned 125 total points
Comment Utility
Try this

Add the image to the report
Right click the image
Click FORMAT IMAGE
Click the PICTURE TAB
Click GRAPHIC LOCATION

You an add a formula here or use a field from the database.

mlmcc
0
 
LVL 18

Expert Comment

by:vasto
Comment Utility
Then just drag the database field which contains the logo to the report
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:MikeM670
Comment Utility
vasto,

I'm going to try both methods for storing or retrieving the image with crystal reports now that the assistance you gave me with the other question.  So I won't close this question out right now.

Mike
0
 

Author Comment

by:MikeM670
Comment Utility
ok I found out that you can't use a Blob in a Crystal formula.  Any idea on why they have this limitation? Would sure make things easier.

if {Agency.AgencyID} = {?Agency}
    then {Agency.Image}
else
    XXXXX

Note:   "Will use a default image for the else statement.  Either blank or the vendor's image.

I've read you can use a stored procedure to make this work so I will give that a shot.

Mike
0
 
LVL 18

Expert Comment

by:vasto
Comment Utility
Drag the BLOB field directly to the report and add a formula to suppress if necessary
0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
Is the image stored in the database?

The graphic formula should return the path to the formula

mlmcc
0
 
LVL 22

Accepted Solution

by:
Ido Millet earned 250 total points
Comment Utility
It sounds like the choice of logo actually depends on who (based on department) runs the report. In other words, each user will always want to see their own logo.

If that is the case, the solution can be very simple. Set the graphic location to a static path and file name (e.g. Dept_Logo.jpg) using local (if running local) or mapped drive (if running on a server). For example:  C:\...\Dept_Logo.jpg  or  P:\...\Dept_Logo.jpg

Obviously, each department would save a different logo under that same file name.
0
 

Author Closing Comment

by:MikeM670
Comment Utility
Thanks everyone.  I tested this and it works properly now.  One thing I noted is when I created some test logos using a 150x150 pixel sized graphic and put some test in them to identify each department it ran perfectly.  But when I ran it based on actual logos that had been converted to 150x150 pixel size some of them displayed larger then the others thus altering the header size.  

I'll work on figuring out the graphics end of this.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

772 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now