In Crystal Reports, you insert a Formula into your report named
@Title.
In VB, you assign it as follows:
Rpt1.Formulas(0) = "Title= " & "The title of your report"
You can find many examples of this by using a Google Groups search
with the following search terms:
formula "Crystal Reports" VB title
Here is a link to the Crystal Reports Knowledge Base
http://support.crystaldecisions.com/library/kbase.asp
Good luck with your reports!
- Hammer |
Request for Answer Clarification by
bigjohnbn-ga
on
11 Nov 2002 04:15 PST
I thought I knew what to do, but when I actually try it, I have
problems.
I have used the Add Crystal Reports 8.5 option from the Project menu
to create the boilerplate code. I have modified the second form the
read as follows:
rivate Sub Form_Load()
Screen.MousePointer = vbHourglass
CRViewer1.ReportSource = Report
Report.RecordSelectionFormula =
"{Receipts.Date}>datetime(2002,10,15,00,00,00)"
'Report.FormulaFields(2).Text = "test"
CRViewer1.ViewReport
Screen.MousePointer = vbDefault
As long as I leave the comment indicator in the Report.FormulaFields
line, the program works OK with the title I created initially.
I can change the selected records with the Record Selection line, so
I'm pretty sure I have the general paramaters set OK.
I can take the comment indicator away on the next line and remove the
title from the report as follows:
Report.FormulaFields(2).Text = ""
However, if I try:
Report.FormulaFields(2).Text = "test"
I get a Crystal Report Viewer error, indicating that "The remaining
text does not appear to be part of the formula"
I have tried several things that don't work. I'm sure this is
something very minor, but I don't know what to do next.
|
Clarification of Answer by
hammer-ga
on
11 Nov 2002 06:58 PST
The string that you pass sets the formula itself, not just the Title
text.
Your code:
Report.FormulaFields(2).Text = "test"
sets the formula itself to "test", which does not evaluate.
I'm also not sure about the FormulaFields part. All the examples I saw
simply said Formulas.
If your formula is named @Title, try something like:
Report.Formulas(0).Text = "Title = test" or
|
Request for Answer Clarification by
bigjohnbn-ga
on
11 Nov 2002 08:03 PST
I had tried something similiar to that. My code now reads:
Private Sub Form_Load()
Screen.MousePointer = vbHourglass
CRViewer1.ReportSource = Report
Report.RecordSelectionFormula =
"{Receipts.Date}>datetime(2002,10,15,00,00,00)"
Report.Formulas(0).Text = "Title = test"
CRViewer1.ViewReport
Screen.MousePointer = vbDefault
I receive an error indicating "Method or data member not found" with
.Formulas highlighted.
If I change it to
Report.FormulaFields(0).Text = "Title = test" I get an error
indicating Subscript out of range.
Report.FormulaFields(1).Text = "Title = test" gives me an error of
"Remaining text does not seem to be part of the formula.
The latest error is a Crystal Viewer error, the others are labelled
"Microsoft Visual Basic" errors.
When I try to type Report.Formulas(0), the program suggests
Report.FormulaFields instead. I have tried all of these combinations
both ways.
I am running VB 6.0 and Crystal Reports 8.5
Any help you could give would be greatly appreciated.
|
Request for Answer Clarification by
bigjohnbn-ga
on
11 Nov 2002 08:33 PST
I found a way to get around my problem. I have created a new table
within the database that I am using. This table contains just the
title that I want to use. I update the table using Visual Basic and
then use that field in the heading of the Crystal Report. It's seems
like a lot of work, but at least it gives the result I want.
|
Clarification of Answer by
hammer-ga
on
11 Nov 2002 10:11 PST
Unfortunately, I don't have a testbed with the same software versions
as you have. I'm glad you found a workaround. If you go to the
Knowledge Base link I sent you and search on "Title", you will find
articles on how to do this using Formula and FormulaFields. Crystal
clearly believes that this can be done from VB, but I don't have the
ability to set up the correct Project References to work it out for
you.
|