Solved

Need help with subreport in Crystal Reports

Posted on 2002-06-13
4
203 Views
Last Modified: 2012-05-04
I want to change a formula in a subreport that is linked to a report I'm printing through VB.  The code so far is:

CReport1.Reset
CReport1.Connect = "DSN=EmployeeProduction;UID=sa;PWD=;DSQ=EmployeeProduction"
CReport1.Formulas(0) = "BegDate = '" & Format(txtBegDateReports.Text, "mm/dd/yy") & "'"
CReport1.Formulas(1) = "EndDate = '" & Format(txtEndDateReports.Text, "mm/dd/yy") & "'"
CReport1.ReportFileName = "\\kclockbox1\checkremit\custom reports\performance\operator.rpt"
CReport1.PrintFileType = crptCrystal
CReport1.Destination = crptToWindow
CReport1.PrintReport

That all works fine, except the subreport.  I want to change the date exactly like I do in the report, just in the subreport also.  How can I do that?
0
Comment
Question by:jackjeckyl
  • 2
4 Comments
 
LVL 2

Expert Comment

by:vbDoc
ID: 7076745
From what I remember about Sub-reports that you can't get to them in a direct method. Here is a work around and there must be others. Create a MDB and pass the new date to the sub-report through it.
Regards
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 50 total points
ID: 7077001
I assume by your crptToWIndow that you ar using the Active X control.
According to my documentation you can look in the Developer's Help file from CR for more details.

Try this

First get the subreport name from CR  by

MSGBox CReport1.GetNthSubReportName (NUMBER)  

Subreports are numbered 0 - N.  I assume 0 is either the first in the report or the first one added.  If you have only 1 then the number is 0.  This will give you name.

CReport1.SubreportToChange = "SUBREPORT NAME"

You can then change things in the subreport such as formulas, pass parameters, etc.

good luck
mlmcc
0
 
LVL 18

Expert Comment

by:mdougan
ID: 7078105
Another option is that you can create a formula in the main report which you can set through VB, and then in the sub-report, you can create a formula that gets it's value from the main report's formula
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 7101311
Glad to help

mlmcc
0

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

832 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