Solved

Check for DataSource before sub report load

Posted on 2004-09-21
8
469 Views
Last Modified: 2008-03-03
Hi,
I am trying to build a report that has multiple subreports.  The datasource for the sub reports is a series of CSV files (using an odbc connection).  The csv files are created by a third party program that performs exports to csv.  If the export is run by the users and there is no data it creates an empty csv file.  That file is then read by Crystal Reports (8.5) and the sub report fails. The sub reports called after it also fail.  I am wondering if there is a way in Crystal Reports to create a check for the datasource before the sub report loads.  It would be ideal if I could check and if the data source does not exist cancel the load of that subreport, thus allowing a load of the next subreport.

Is this possible in Crystal reports?  I have seen the Alert feature, but I am not sure how to check for the health of the data source.

Any help you could give would be much appreciated.

Casey
0
Comment
Question by:Casey Santos
  • 3
  • 2
  • 2
8 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 12119818
I can't think of any way to do that without using some kind of front end application or perhaps another csv files that has the count of the records in the various other csv files.

You could then use that information to suppress a given subreport.

mlmcc
0
 
LVL 10

Accepted Solution

by:
ebolek earned 25 total points
ID: 12122121
You can simple do it in an application like this

1. Create  windows or web form
2. Insert a crystal web/windows viewer to the form
3. Create a dataset and use that dataset as your report;s datasource.
4. Load the dataset with data
5. You cehck if the report's dataset is empty. If it is you exit the application, if not bind the datset to the report documeny and load the dataset tothe reportviewer.

Regards
Emre
0
 

Author Comment

by:Casey Santos
ID: 12122344
I am avoiding using a separate application because the Crystal Report file already is being used through a viewer in the Third Party application.  We would like to keep it as integrated as possbile for the users.


mlmcc, I would be interested to know how you would use a separate CSV file to count the records in the other files.  How would you suppress the subreport then?

Thanks,
Casey
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 10

Expert Comment

by:ebolek
ID: 12122399
Good luck
0
 
LVL 100

Assisted Solution

by:mlmcc
mlmcc earned 100 total points
ID: 12122542
As ebolek says, this may be difficult.  I will need to think this through and need more information

First - I suspect you cannot change the exporting routines.  

Is there a main report that has a dataset?  If so is there any indication in that data that a subreport is empty? I doubt it.

How many subreports?  Is this a single report or is this something you want need for many reports?

Main basic idea is to use variables which are set from the new dataset.  The variables are then used to suppress a subreport if the dataset is empty.

Can you try something to see if this idea might work?
Take a set of the csvs with a known empty dataset.
Suppress the related subreport and see if the report runs.

mlmcc
0
 

Author Comment

by:Casey Santos
ID: 12128313
mlmcc, I think you have got it.  We have tried to surpress one of the subreports and then emptied the csv file.  The entire main report runs and skips the surpressed subreport.  So now we are going to create a different csv file datasource that reads all of the other csv files, checking them for data.  A flag will be set for each csv file that is missing data.  We will then use the csv file with these flags to set the surpression of each of the respective subreports.  We will do this tomorrow and let you know how it goes.

Thanks,
Casey
0
 
LVL 10

Expert Comment

by:ebolek
ID: 12338694
I think both mlmcc and I gave the right answers. He could use both explanations so I recommend mlmcc & ebolek

Comment from ebolek
Date: 09/22/2004 05:31AM PDT
Comment from mlmcc
Date: 09/22/2004 06:20AM PDT
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

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…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

813 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

13 Experts available now in Live!

Get 1:1 Help Now