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

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,
swami_varahagirAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mlmccCommented:
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
swami_varahagirAuthor Commented:
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
vidruCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

swami_varahagirAuthor Commented:
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
vidruCommented:
Make sure you're including the '.rpt' extension in the subreport names.

-dave
0
swami_varahagirAuthor Commented:
yes it is included
0
swami_varahagirAuthor Commented:
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
vidruCommented:
You need set the Connect property for each subreport as well.

-dave
0
mlmccCommented:
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
swami_varahagirAuthor Commented:
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
mlmccCommented:
Does it work for any 2 or does one of the reports cause a problem?

mlmcc
0
swami_varahagirAuthor Commented:
it works for any 2 and when I add 1 more it gives the error Error detected by db dll

Thanks,
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.