Solved

Need help with subreport in Crystal Reports

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…

759 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now