| Author |
Message |
nathaniel
Newbie
Joined: 23 Feb 2012
Location: Germany
Online Status: Offline
Posts: 6
|

Topic: Commit a formula as parameter Posted: 23 Feb 2012 at 4:14am |
Hello, first of all: I am using Crystal Reports 11 and got a problem with a report. - I got one main report and 3 subreports
- The main report have 2 parameters
- Those 2 parameters are "DateTimeFrom" and "Mode"
- If "mode" is selected on "automatically" , it will get the value of the CurrentDateTime
- Otherwise it will get the date, which the user types into the parameter window (after pressing F5)
- The subreport will only get one date (CurrentDateTime or that Date which the user typed in)
Thats my code for that idea:
if {?mode} ="automatically" then CurrentDateTime else {?DateTimeFrom}
Until that part it works great, because if I insert the parameter "Mode" into the main report and take a look on the date, it always gives me the right one.
So, i want to send that date, which "mode" calculate, to my subreport. Therefore i opened the subreport assignment and put the "mode" into it. A new parameter field for the subreport have been created too. Its called ?Pm-@Mode.
But if i start the report now, i dont get my subreport. I only get the main report. The subreport looks like an empty space. If i click on it, its loading the data and i can see the subreport after a few seconds. Well, thats the problem because i dont want to load it AFTER clicking on it.
Hopefully someone can help me out.
Peace Out
|
IP Logged |
|
|
|
rkrowland
Senior Member
Joined: 20 Dec 2011
Location: England
Online Status: Offline
Posts: 259
|

Posted: 23 Feb 2012 at 4:39am |
I'm not sure I'm following correctly based on your description, but the jist of what I got is you want to pass whatever date is used in the main report to your subreport?
If that's the case, your subreport doesn't need a mode parameter - all it needs is a date parameter for whereever you use the date, then link that parameter to the formula you use above in your main report.
Let me know if I'm misunderstanding you.
Regards,
Ryan.
|
IP Logged |
|
kostya1122
Senior Member
Joined: 13 Jun 2011
Online Status: Offline
Posts: 475
|

Posted: 23 Feb 2012 at 5:47am |
|
from what i understated your almost there
in select expert(main report) you probably have something like
(
if {?mode} ="automatically" then table.date_field=CurrentDateTime else table.date_field={?DateTimeFrom}
)
in your sub report you need to do the same thing you did with parameters
in your main report
then just right click on sub report select change sub report links and
link your parameters from main report to the parameters from you sub report.
|
IP Logged |
|
nathaniel
Newbie
Joined: 23 Feb 2012
Location: Germany
Online Status: Offline
Posts: 6
|

Posted: 26 Feb 2012 at 9:40pm |
|
Thanks for your replies.
@rkrowland:
Yes thats right. When the mode "automatically" is selected, i want to pass to the subreport and send him the "CurrentDateTime". Else it will get the DateTime which the user typed in.
My subreport doesn't have a mode parameter. It just have one parameter which is called "PM-@datetime". That parameter will get the currentdate or the date which the user have typed in (depending on the mainreport).
Thats how it works:
Settings for the Mainreport:
1. User types in a date e.g. 2010-05-30 00:00:00 Parameter: DateTimeFrom
2. User selects mode: [Manual] [Automatic] Parameter: Mode
3. I created one formula which is called: DateForSub
DateForSub:
if {?mode} ="automatically" then CurrentDateTime else {?DateTimeFrom}
Settings for the Subreport:
(right-click on the subreport, "join-options" (i don't know how its exactly called in english but it should be something like this. Its the sixth option)
Then I pasted the DateForSub into it.
Subreport-Settings
@kostya:
The subreport will get one date. It doesn't matter what mode it is. Why?
Because the settings for subreport are that it will get the formula. (I already explained that above.
I hope i could explain it better now but if you have any further questions please ask. If you have any idea i would be very thankful.
|
IP Logged |
|
rkrowland
Senior Member
Joined: 20 Dec 2011
Location: England
Online Status: Offline
Posts: 259
|

Posted: 26 Feb 2012 at 10:48pm |
I just re-read your first post, I think the description of what your process is actually misdirected me away from what the problem is.
Originally when I read it, I didn't realize that the subreport is actually working correctly when clicked.
It sounds to me like the sub-report is setup to be "on-demand", meaning it will only work when clicked. To change this right-click the subreport, select Format Subreport (2nd option), then select the Subreport tab (last tab) and then untick on-demand subreport (first checkbox).
Hopefully that should fix your problem.
Regards,
Ryan. Edited by rkrowland - 26 Feb 2012 at 10:49pm
|
IP Logged |
|
nathaniel
Newbie
Joined: 23 Feb 2012
Location: Germany
Online Status: Offline
Posts: 6
|

Posted: 26 Feb 2012 at 11:54pm |
|
Hey Ryan,
thanks for your respond but that option would be to easy to solve the problem :-)
I already tried that but it didnt help.
|
IP Logged |
|
rkrowland
Senior Member
Joined: 20 Dec 2011
Location: England
Online Status: Offline
Posts: 259
|

Posted: 27 Feb 2012 at 12:18am |
Hmm, that's the only thing I can think of if the subreport is working fine when clicked. There's obviously nothing wrong with the links.
Maybe the data is being displayed in the main report just isn't shown due to size constraints? The main report will display all sections of a subreport, if you have any white space at the top of the subreport this will be all that's displayed in the main report if the size of the subreport box isn't big enough.
Try increasing the size of the subreport box on your main report and also try ticking "Can Grow" in the format subreport dialog.
Regards,
Ryan.
|
IP Logged |
|
nathaniel
Newbie
Joined: 23 Feb 2012
Location: Germany
Online Status: Offline
Posts: 6
|

Posted: 27 Feb 2012 at 12:39am |
|
I have already tried that out too. But it didn't help. :-( But I have noticed another thing: When I export the file on our crystal report server it works. => You can see all the tables and all data it contains.
Probably its a bug or something like that. Otherwise I cant explain it.
|
IP Logged |
|
rkrowland
Senior Member
Joined: 20 Dec 2011
Location: England
Online Status: Offline
Posts: 259
|

Posted: 27 Feb 2012 at 12:52am |
Is there any formatting in the subreport which would prevent it from displaying correctly in your main report? White font on a white background for example?
Maybe try re-inserting the subreport?
|
IP Logged |
|
nathaniel
Newbie
Joined: 23 Feb 2012
Location: Germany
Online Status: Offline
Posts: 6
|

Posted: 27 Feb 2012 at 1:24am |
|
No its not. I also tried to make a test report where i tried too do it. You could test it easily too. Just create a report with a subreport and create two parameters in the main report.
Mode and DateTime. Then you write a formula as i did and join it to your SubReport.
And in the subreport you just put the parameter into it too see if it works.
|
IP Logged |
|
|
|