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

I'm new to CR and am trying to figure out parameters.

Status
Not open for further replies.

artyk

Programmer
Apr 5, 2006
163
US
Hi, I am trying to create a simple parameter in CR for a date value, but when I create the field and select the date I want to filter on, I get all results from all dates. I was just wondering if there might be a setting I'm missing or something. What I have done so far is this: I created a new parameter field, named it, set up the prompt, and added it to the report. When I run the report it prompts me for the date, but never uses the date I entered. I am using CR 10 with Visual Studio 2005. Any help would be greatly appreciated. Thanks!
 
Nevermind. I figured out a way to do what I was trying to do. Thanks anyway.
 
I figured out the first part of what I was trying to do which is to limit records in the report to a particular date, however I am still having a related problem that I haven't been able to find a solution to as of yet. Basically what I need to do is give a point total for a particular week (something I've been able to do successfully), but also give a point total for the quarter thus far. So, in one respect I need to limit the records that I am pulling to only a week's worth of data, but on the other hand I need to be able to accumulate points for the entire quarter to date. I know how to accumulate with formulas, however, I'm not sure to tell it that for this portion I don't want to limit the records. I thought of using a subreport, but it doesn't look like I can reference fields from the original report, which I presume I will need to do. Again, any help would be greatly appreciated.
 
It sounds like you need a subreport to me. The main report can be for the given week, which you already have, and the Subreport can be set up for Quarterto-Date. There is not a "period" for Quarter-to-Date, but you could probably write a selection formula using current date.

Give it a try...
 
Will do, thanks. I'll keep you posted.
 
I would not use a subreport.

I would make the record selection formula the quarter you are interested in, then conditionally suppress the records that you want to have calculate in the quarter figure, but not display.

This will require you to use running totals or variables for the weeks worth of data you are displaying to total properly, but normal inserted summaries will contain all record's values, including those that are conditionally suppressed.

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports

"If you have a big enough dictionary, just about everything is a word"
--Dave Barry
 
I tried to follow your advice, dgillz, and now I'm approaching the problem from the other way, first getting all the records and trying to narrow it down from there. I started with pulling in all the records in the database. This is because the quarter number will not be input by the user, only the date will. The good thing is that the quarter number is stored in the table with the date. It should be fairly easy to pull that value out and limit the records to that number using the date as an intermediary, but I just don't know quite how to do that with CR. In VB it would be simple and probably is in CR also, but it's a little different from what I'm used to. I have a statement similar to this as my group formula, but it's not working the way I expected.
Code:
If {Points.Date} = {?Date} Then x = {Points.Quarter};
{@UnboundNumber1} = x
I was hoping this would display the quarter that the date fell under in an unbound field so I could see if it was actually pulling the quarter number, but it doesn't seem to be doing that much even. I think I'm on the right track, it's just that I'm not too familiar with CR and I'm still kind of feeling my way around it. If you have any more suggestions I would appreciate it, but like I said, I think you've pointed me in the right direction, I just need to figure out the specifics. Thanks.
 
Are you using vb syntax or crystal syntax.

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports

"If you have a big enough dictionary, just about everything is a word"
--Dave Barry
 
To restrict your report to the quarter, go to report, selection formulas, record, and enter:

{YourDateField} in date(2007,7,1) to date(2007,9,30)

You can make the start or end dates above formulas or parameter fields.


Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports

"If you have a big enough dictionary, just about everything is a word"
--Dave Barry
 
I see where you are going, but I was hoping there would be a way to do it without something like that since I already have the quarter number recorded in the table.
 
You can replace the dates in the formula above with another expression, parameter, or database field.

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports

"If you have a big enough dictionary, just about everything is a word"
--Dave Barry
 
At the moment I have a situation where I have a counter set up in the details section where it counts the number of records that fit in that particular quarter. That number is later used as a dividend in another formula. I am getting a "dividing by zero" error apparently from that counter. Here is my formula.
Code:
numberVar z;
If {Points.Quarter} = {@UnboundNumber1} then z + 1
Else 0

I suspect the problem is with "@UnboundNumber1" (which is to display the quarter number), but I don't know of a way to track it during runtime to see what's happening. Can I not reference a field in that way? Or is there a better way to use that value? I think I'd be making progress if it weren't for that.
 
Nevermind, I think I may be on to something. It may not be the slickest solution, but it seems to be working. I'll keep you posted.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top