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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parameter based on a Group or Formula? 1

Status
Not open for further replies.

piovesan

Technical User
Jan 23, 2002
159
CA
Hi there. I would like to create a parameter that queries a date field (called StartTime), but I want the user to be able to query by just the month and year, rather than the whole field (day, month, year). I have the report grouped on the StartTime field, and I have set the group to display for each month. Can I create a parameter using this grouping?? Or is there someother way of creating the parameter based on the StartTime field so that the parameter is just a drop down of months?? I thought maybe I could fo it by creating a formula field from the Group like this:
GroupName ({InsMaster.StartTime}, "monthly")
But I am not sure that is the correct way....
Thanks!!
 
You could specify month number as a parameter, value 01 to 12. Also a year, assuming it is not always the current year, but it could default to 9999 for the current year, or to 00 if you won't want the year 2000 or earlier.

You then use it as a test, something like
Code:
if @ParamYear = 9999
then Year(currentdate)
else ParamYear
Code:
Month({your.date}) = @ParamMonth
and
Year({your.date}) = @YearFromParam

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 11.5 with SQL and Windows XP [yinyang]
 
I'm not sure that I understand.... OK... So, I create a parameter called ParamYear which is a number, and I manually type in years as a value:
2012
2011
9999
etc.
THEN I create a formula called @yearfromparameter using:
if {?ParamYear} = 9999
then Year (currentdate)
else {?ParamYear}

I also create a parameter called ParamMonth which is also a number, and I manually type in months, 1-12 (can't be 01 because it's a number and not a string)....
THEN I create a formula called @monthfromparameter using:
Month ({InsMaster.StartTime}) = {?ParamMonth}
and
Year ({InsMaster.StartTime}) = {@Yearfromparameter}

THEN I add the formula @monthfromparameter to the report.... I get prompted for those two parameters.... but it doesn't seem to work.... I am still getting the whole database....
Did I miss something??
Thanks!
 
oops... I did miss something!! I missed adding the formula @monthfromparameter to the report select expert!!

This works!
Thanks!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top