Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Crystal Subreport Object Path
Message
From
16/04/2004 13:32:50
 
 
To
16/01/2004 15:21:07
General information
Forum:
Visual FoxPro
Category:
Crystal Reports
Miscellaneous
Thread ID:
00866961
Message ID:
00895631
Views:
20
Craig, here's an update on this thread, and another question. I paid Business Objects their $195 clams for a tech support incident and submitted the subreport question detailed earlier in the thread--their responses in bold, mine in italics:

------------------------------------------------------------------------------------------------
I think the UNC path is the issue here. There is no method via which you can pass a new path for the subreport. But there are other ways out of this issue.

1) Use the same path on all computers. For example, C:\myapp_path\logosubreports\
2) Rather than using a subreport, use linked OLE Object as the logo
3) Rather than using a subreport, use a picture and re-import it at runtime. See VB code below (I do not have VFP code)
4) Similar to (2) above, go through the sections of the report, when you find the subreport you need, replace it with another report.


Correct me if I am mistaken, but:
1. Solution One is not practical, it would require that we force all users to install in exactly the same path on every machine, and there is no guarantee that everybody in the world has a C:\PROGRAM FILES\MYCOMPANY\MYAPP folder that is viable.
2. Solutions 2 and 3 both require that the graphic is the same size and shape in every case. With changing logos, that is an impossible restriction.
3. Also, both 2 and 3 do not allow the end user to change other features of the subreport, like text, font size and color, text positioning, and so forth.
4. I thought #4 was my solution also, and I wrote code almost identical to that you provided to loop through the object model, find the appropriate subreport, delete it, and then replace it with a new one, new path included. Unfortunately, I need to do this on ALL user's machines, in a view-only environment. When I do that and they do not have an RDC runtime license installed, I get an error message that says I must have "report creation licensing" or words to that effect. So I can get a reference to the subreport object just fine; I just can't do anything useful with it. If there is any way around that, I would sure like to hear it.


Ray, your interpretation of all of the points is correct. Please note that I only support the product and I do see your frustration. I attempted to provide all possible avenues to resolve the issue you are dealing with, in the hope that one of them would be suitable. As this is not considered to be a bug, I do not think we are going to get a quick "fix" for the issue.

Suppose I have an application with 500 reports and that application is being used by 100 customers. Neither of those numbers are unreasonable.
Nor is the desire of each of my 100 customers to have their own logo and header information appear at the top of their set of 500 reports. So how do I accomplish that using Crystal Reports?

According to what you have told me, I would have to store 500 X 100 or 50,000 separate reports somewhere on my system and distribute them in individual sets of 500 to each customer!

You are telling me that using a subreport that is customized for each customer will only work IF every customer uses exactly the same format in their letterhead, with a logo graphic of exactly the same size. For those of us who live and work in the real world, that is completely unrealistic.


Ray, If I was designing something like this I would think every customer would have their own logo, which will have different sizes and other attributes. These logos may be in different formats, BMP, GIF, TIF, JPG or what ever. If that is the case, it is difficult to cover all the cases, if I do not know which format the logo is in ahead of time and thus, using the subreport method, or any other method will present a challenge.

If the customer wants to use their logo, I suspect they will want this to have certain dimensions on the report. How do I ensure these dimensions are correct, irrespective of the method used to show the logo?


Almost any letterhead would fit in the top inch or two of the page, so if I provide all reports with a 1.5" space for a logo/header subreport at the top of the page, and then ship a single customized subreport to each customer for that purpose, I not only don't have to do any modification whatsoever to the main body of the rest of my reports, the end user has the capability, within the constraints of the top 1.5" to change their "look" to anything they like without any intervention on my part. That is far more logical and far less restrictive than forcing the logo graphic into a fixed size, shape, and position and eliminating any ability to change font name, size, color, etc.

Only apparently I can't do this because Crystal has made an extremely poor design decision with regard to activating the subreport object. It is obviously even contrary to your own design intent, given the presence of the “Re-import When Opening” checkbox for subreport objects. What is the point of that if it only works on the original development machine?

I can't even attempt your earlier suggestion of keeping the path name the same for all distributed reports, because the stored path is a UNC path that includes the machine NAME on the developer's machine. So now what, I'm supposed to force all my customers to rename all of their workstations to the same name I use here?


Ray, I think we're hashing over the same explanation and in a nut shell, yes you are correct.
-----------------------------------------------------------------------------------------------------

So, that's the end of that. I'm attempting to create a work-around for myself and perhaps my customers as well. So I wrote the following code in an attempt to programmatically replace the logo subreport on the fly: (other Crystal users, note that this code requires a Crystal RDC license, NOT included in the developer's edition)
WITH this && oCrystal wrapper object
	*- Set the report object to nothing
	.oReport = .NULL.

	*- get the file name
	lcPath = FULLPATH(CURDIR())
	CD (lcPath + 'CRYSTAL\REPORTS')
	lcFile = GETFILE('rpt','Open Report File:','Open',0,'Open Existing Report')
	CD (lcPath)
	lcNewSubFile = GETFILE('rpt','Open Subreport File:','Open',0,'Open Subreport')
	
	IF !EMPTY(lcFile) AND !EMPTY(lcNewSubFile)
		lcSubReportFile = lcPath + "CRYSTAL\REPORTS\" + JUSTFNAME(lcNewSubFile)
		lcOldSafety = SET('SAFETY')
		SET SAFETY OFF
		COPY FILE (lcNewSubFile) TO (lcSubReportFile)
		
		.oCrystalApp = CREATEOBJECT("CrystalDesignRuntime.Application")
		.oReport  = .oCrystalApp.OpenReport(lcFile,1) && tried with both zero and 1 as second parameter
		
		WITH .oReport
			loSec = .Areas(1).Sections(1)
			loSub = loSec.ReportObjects(1)
			loSec.DeleteObject(loSub)
			loSec.ImportSubreport(lcSubReportFile,0,0)
                        .SaveAs(lcFile,2048) && error: "Unable to write to <lcFile>, it is read-only or opened by someone else."
		ENDWITH 

		SET SAFETY &lcOldSafety
	ENDIF && !EMPTY(lcFile) AND !EMPTY(lcNewSubFile)
ENDWITH && this
Is there some way to avoid the error in the .SaveAs() method? Yeah, I know, save it to another directory; but I was hoping to be able to open-alter-save all in one operation. Guess not, huh?
Ray Roper
Previous
Reply
Map
View

Click here to load this message in the networking platform