Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Calling a report from VB, which has multiple subreports independent of each other

Posted on 2004-10-27
12
Medium Priority
?
2,629 Views
Last Modified: 2008-01-09
Hi ,

I have a main report which contains no  fields to display and not based on any query. It is derived from the base table on which other sub reports are based. This main report contains 4 sub reports. Now when I am calling the main report from VB passing the SqlQuery to it. Instead of displaying the reports based on the query it gives an error, can not open SQL Server. Error number 20599. My DB Is Oracle 9.

How do I achieve to display the reports.

Thanks,
0
Comment
Question by:swami_varahagir
[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
  • 6
  • 3
  • 3
12 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 12424065
How are you passing the query?

You need to pass it to each subreport not just the main report.

Look at

http://support.businessobjects.com/communityCS/FilesAndUpdates/SCR8_VB_RDC_Subreports.exe.asp

mlmcc
0
 

Author Comment

by:swami_varahagir
ID: 12424308
This is my Code

        rptTACTICS.Connect = GetConnectionString
        rptTACTICS.WindowState = crptMaximized
        rptTACTICS.Destination = crptToWindow
        rptTACTICS.ReportFileName = App.Path & "\Report\Attribute_Info_Report.rpt"
        rptTACTICS.DiscardSavedData = 1
        rptTACTICS.SQLQuery = strQuery & strDateCriteria
        MsgBox rptTACTICS.SQLQuery
        rptTACTICS.Action = 1


Where as rptTactics is the ocx and Attribute_Info_Report.rpt is the main report.

Now I hv to display the subreports based on the query passed to main report.

Thanks,
0
 
LVL 13

Accepted Solution

by:
vidru earned 2000 total points
ID: 12424697
To access the subreports, you need to use the SubreportToChange property, which is not very elegant, at all.

'Change the SQLQuery for the first subreport
rptTACTICS.SubreportToChange = "Subreport1"
rptTACTICS.DiscardSavedData = 1
rptTACTICS.SQLQuery = strQuery & strDateCriteria
'Set the focus back to the Main report
rptTACTICS.SubreportToChange = ""
'Change the SQLQuery for the second subreport
rptTACTICS.SubreportToChange = "Subreport2"
rptTACTICS.DiscardSavedData = 1
rptTACTICS.SQLQuery = strQuery & strDateCriteria

From the ocx help files:

     SuberportToChange Property:

     Description

     Specifies whether changes to any of several properties (see list in Remarks below) affect the main report or a subreport.

     Usage

     [form.]Report.SubreportToChange(= SubreportName$)

     Code Samples

     With CrystalReport1
     
     .ReportFileName = "C:\rpts\Report.rpt"
           .SubreportToChange = "SubRpt1"
           .Action = 1
     
     End With
     
     «Any properties following the SubreportToChange will apply to the Subrpt1 subreport»
     
     Remarks
     
     When the SubreportToChange property is set to an empty string, focus returns back to the main report.
     
-dave          
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:swami_varahagir
ID: 12425045
Thanks for the help but I am getting the error "Unknown Subreport Name".
Plz let me know why and how do I resolve it.


The subreports are independent reports and placed in the main report header as sub reports(Choose a file as Subreport option)

Thanks,
0
 
LVL 13

Expert Comment

by:vidru
ID: 12425067
Make sure you're including the '.rpt' extension in the subreport names.

-dave
0
 

Author Comment

by:swami_varahagir
ID: 12425144
yes it is included
0
 

Author Comment

by:swami_varahagir
ID: 12425290
Yes I did. I was passing the report name with the complete path. I have changed it now and the cide is as follows.

        rptTACTICS.Connect = GetConnectionString
        rptTACTICS.WindowState = crptMaximized
        rptTACTICS.Destination = crptToWindow
        rptTACTICS.ReportFileName = App.Path & "\Report\Attribute_Info_Report.rpt"
        rptTACTICS.SubreportToChange = "Drug_Attribute_Info_Report.rpt"
        rptTACTICS.DiscardSavedData = 1
        rptTACTICS.SQLQuery = strQuery & strDateCriteria
        rptTACTICS.SubreportToChange = "Investigator_Attribute_Info_Report.rpt"
        rptTACTICS.DiscardSavedData = 1
        rptTACTICS.SQLQuery = strQuery & strDateCriteria
        rptTACTICS.SubreportToChange = "Country_Attribute_Info_Report.rpt"
        rptTACTICS.DiscardSavedData = 1
        rptTACTICS.SQLQuery = strQuery & strDateCriteria
        rptTACTICS.SubreportToChange = "CROPS_Attribute_Info_Report.rpt"
        rptTACTICS.DiscardSavedData = 1
               
        rptTACTICS.SQLQuery = strQuery & strDateCriteria
        MsgBox rptTACTICS.SQLQuery
        rptTACTICS.Action = 1

And I am getting an error in the last line (.Action = 1) .

The error is "Can not open SQL Server". My DB is Oracle and I am using odbc for Oracle System DSN.

Waiting for a quick solution.
Thanks,

0
 
LVL 13

Expert Comment

by:vidru
ID: 12425314
You need set the Connect property for each subreport as well.

-dave
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 12425352
The subreport name is the name shown in Crystal designer which is not necessarily the file name.

Also before rptTACTICS.Action = 1
 add a line
rptTACTICS.SubreportToChange = ""

This resets the report object to the main report.

mlmcc
0
 

Author Comment

by:swami_varahagir
ID: 12425868
It is working fine for 2 subreports but when I am including more than that (I need to display 4), it gives Error detected By Database DLL.

0
 
LVL 101

Expert Comment

by:mlmcc
ID: 12425931
Does it work for any 2 or does one of the reports cause a problem?

mlmcc
0
 

Author Comment

by:swami_varahagir
ID: 12425984
it works for any 2 and when I add 1 more it gives the error Error detected by db dll

Thanks,
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
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…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

610 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