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

Display only current year information 2

Status
Not open for further replies.

Eaklor

Programmer
Nov 11, 2004
1
US
I have built an application that uses SQL database and Crystal Reports that is embedded in Visual Studio 2002. The application is running well and the Reports are working well. I have a main report with sub-reports. I have a formula to calculate month to date and year to date. As soon as I added data to the database for 2005 I now get two rows of data for 2004 and 2005, although 2004 is showing 0's. Can anyone help me determine the proper formula to display only the current year. The following is the formula format for year to date:

if {mytable.myDate} in Date(year({?Date}),1,1) to {?Date} then (x+y)

where: ?Date = parameter, mytable = table, myDate = Current date

Thank You Julie
 
This looks like a formula to calculate something that you would place on the report canvas. You would also have to place a formula in the record selection area (report->edit selection formula->record) to limit the records:

{mytable.myDate} in Date(year({?Date}),1,1) to {?Date}

You would want to place a similar formula in your subreport record selection formulas (creating the parameter in each, too), and then link the main report to the subreports on the parameter field. Be sure to use the dropdown in the bottom left corner to access the subreport parameter {?Date}, NOT {?pm-?Date}.

-LB
 
If you wish to limit data in the report to only the year of the parameter go into the Report->Edit Selection Formula->Record and try:

{mytable.myDate} in Date(year({?Date}),1,1) to {?Date}

Now the report will only pull data for the year of the parameter.

Note that stating "As soon as I added data to the database for 2005 I now get two rows of data for 2004 and 2005, although 2004 is showing 0's." doesn't help unless you state whether the intent was to pull 2004 or 2005.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top