Solved

Need help with subreport in Crystal Reports

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

840 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