Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying Search Critera on Report 1

Status
Not open for further replies.

mimama

IS-IT--Management
Nov 26, 2000
3
US
I have a project where I have to display reports I've made using Crystal Reports from a VB application. I know there is a way to change the selection criteria for the report in VB (using the SelectionFormula method). I was wondering if there is a way to display the selection critera in the report generated?

So if I wanted records with dates between 06/20/1999 - 07/19/2001 is there a way to insert this date range into the report.

Thanks for anything you can give me
 
In later versions of Crystal you can add a special field called RecordSelectionFormula onto the report. However, depending on how you pass the formula in you may not get the literal dates.

If this doesn't work, or isn't availble, and you are passing the dates in from the application, you can also pass these values to a formula field that you can print on the report. The formula can be a string assembled in VB and passed as a literal to a CR character formula field, placed at the appropriate place on the report. Ken Hamady
Crystal Reports Training and a
Quick Reference Guide to VB/Crystal
 
Thanks Ken,

The RecordSelectionFormula field isn't available on the CR I have (I think its 4.9). I'm new to CR and the help documentation isn't giving me what I need. First of all, how do I set up the formula field in CR, when I insert it I put the formula {table.date} > Date{2000, 6, 19}. The label is treated as a boolean (it says true or false) and it does not say the date.

Second how would I pass the date in from VB? Is there a way to access the formula field and change its caption? Thanks again
 
You probably have V4.6 of crystal, which comes for free with VB.

Put the formula in quotes and it won't be a boolean anymore, it will be a character string. Place the formula itself on the report header or footer to see it only once. Delete the column heading text for this formula.

There is a method to overwrite the contents of any formula. Something like:

rptMyReport.Formulas(0) = "new string" Ken Hamady
Crystal Reports Training and a
Quick Reference Guide to VB/Crystal
 
{table.date} > Date{2000, 6, 19}
The database is going to substitute date values for {table.date} into this formula. So, things like
December 25, 2000 > Date{2000, 6, 19}
which result in a "True", or "Yes" value, because Christmas is later than June 19.
If you are using a record selection formula, you need to pick records that meet a certain criteria, or test. They pass the test (in which case they are selected), or they are rejected. The record selection formula always has to have a formula that returns a boolean value (Yes/No, True/False, Pass/Fail). A record selection formula that just returns a date would not a "selection".
However, if you just want to see the date, you can make another formula like
Date{2000, 6, 19}

What do you mean by changing the caption of a formula? You can get and set the contents of formulas from VB, but don't know what you mean by the caption. Malcolm
wynden@telus.net
 
Thanks Ken, & Malcolm,

Malcolm -- sorry, what I meant to ask was how I would change what the formula field displays. In this case the Start Date and End Dates. Thanks all.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top