Solved

Need help with subreport in Crystal Reports

Posted on 2002-06-13
4
205 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 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

696 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