PDA

Click to See Complete Forum and Search --> : [RESOLVED] CR4 runtime parameters


PeterBorroloola
Mar 24th, 2006, 02:44 AM
Hi all,

Apologies to readers of the Xtreme forum; I wasn't getting any bites there.

I'm putting together a front-end for an Access 97 db using VB6 and CR4.

Yes, I know CR4 is ancient history, but I'm a part-time as-needs-be programmer, and I can't justify the expense of a developer edition of a later CR.

I want to produce reports on the data, using an identical report (layout-wise) but with different sets of data. So I should only need to distribute one report file, which I can manipulate at runtime to show the different result sets. I can adjust the data itself, using the .SelectionFormula and .SortFields runtime properties in the VB code.

What I want to do, and I'm having trouble with, is putting a heading on each report, which will differ for each of four different data sets.

I can't find a way of passing a text field to CR4 from VB6. I tried inserting a db field in the report, then creating a table in the db to hold just one record: the required heading, which I could set at runtime. But that didn't work, the records did not display at all, whether the heading was in the 'Title' or 'Page Header' section.

Of all the methods and properties that the CR4 object lets you pass to VB6, the only one that looks useful is 'BoundReportHeading' - but that just sets the title of the report, and I can't see any way to print that with the report.

any ideas gratefully accepted, Peter

Hack
Mar 24th, 2006, 05:32 AM
How aboutCrystalReport1.ReportTitle = "Whatever"Is this what you mean?

PeterBorroloola
Mar 24th, 2006, 06:17 AM
hack, the cr4 help file for that property says:

"The value of the ReportTitle is not displayed in any part of the report, but is provided for your own use."

you have to wonder why they bother then, really.

I think I'll need a trickier workaround, but it's got me beat for now.

PeterBorroloola
Mar 24th, 2006, 07:14 AM
ok, uncle peter's got it sorted. using the 'formulas' property, it goes something like this:

Dim ReportHeading As String

....

If optReport(3).Value = True Then
ReportHeading = "Men's chronic disease reviews for " & Format(Now, "mmmm")
Else
ReportHeading = "Men's chronic disease reviews for " & Format(DateAdd("m", 1, Now), "mmmm")
End If

....

crpReports.ReportFileName = "cddb.rpt"

crpReports.Formulas(0) = "heading = " & Chr(34) & ReportHeading & Chr(34)
crpReports.PrintReport

There is a Formula field in the report called 'heading', which this code feeds.
Voila! Knew there had to be a way.

thanks, Peter

Hack
Mar 24th, 2006, 08:07 AM
Thanks for posting what you found. :thumb: