Solved

Need help with subreport in Crystal Reports

Posted on 2002-06-13
4
206 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
[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
  • 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 101

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 101

Expert Comment

by:mlmcc
ID: 7101311
Glad to help

mlmcc
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…
Suggested Courses
Course of the Month4 days, 5 hours left to enroll

630 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