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

Month value dynamically default to current month 2

Status
Not open for further replies.

northw

MIS
Nov 12, 2010
140
US
Hi all,

I have a report with month parameter( (JAN, FEB, MAR ...)String value), users want to see current month as the default value, can this be done?

I can leave it as optional prompt, but users want to have that prompt and a default value of current month.

Crystal reports 2008, Oracle 11g.

Thanks in advance!
 
NorthW,

In my version of CR (10), there is a button on the dialogue box for creating a Parameter called "Default Value". This is the same as when you "edit" an existing parameter. The subsequent dialogue box should provide you with the options needed to set up a default. I haven't worked much with dynamic paramters, but I would think it possible.

[blue]Month[/blue]([blue]CurrentDate[/blue]) would return 7 for today.
[blue]MonthName[/blue]([blue]Month[/blue]([blue]CurrentDate[/blue])) would return "July"
[blue]MonthName[/blue]([blue]Month[/blue]([blue]CurrentDate[/blue]),[blue]True[/blue]) should return "Jul"
[blue]UpperCase[/blue]([blue]MonthName[/blue]([blue]Month[/blue]([blue]CurrentDate[/blue]),[blue]True[/blue])) should return "JUL"

Might take some playing around, but hopefully this gets you going in the right direction. [smile]

Cheers!

Mike
---------------------------------------------------------------
"To be alive is to revel in the moments, in the sunrise and the sunset, in the sudden and brief episodes of love and adventure,
in the hours of companionship. It is, most of all, to never be paralyzed by your fears of a future that no one can foretell."
 
Thanks Mike for the reply,
I think I did not explain it correctly, the requirement is if the users open the report in June they should see Jun as the default value, in July it should be JUL and so on..
as far as I know I can enter a value for the default, but I am not sure how to make that dynamic to change every month?


Thanks!
 
NorthW,

The "simplest" way around it I can think of is to all "Current" as the default text option, and conditionally setup your report criteria when "current" is chosen.

If you could provide your current Selection Criteria, myself (or another TekTipper) should be able to assist you further, but with the information provided, I unfortunately cannot help with specific syntax.

At a very high level it would look something like:
Code:
[blue]IF[/blue] {@Parameter} = "Current" [blue]THEN[/blue] {Table.SomeDateField} = [blue]Month[/blue]([blue]CurrentDate[/blue]) [blue]ELSE [/blue]
[green]|| Your Existing Selection Criteria ||[/green]

Hope this helps! Cheers!

Mike
---------------------------------------------------------------
"To be alive is to revel in the moments, in the sunrise and the sunset, in the sudden and brief episodes of love and adventure,
in the hours of companionship. It is, most of all, to never be paralyzed by your fears of a future that no one can foretell."
 
Erm... Sorry, I goofed the mock up.

Code:
... [blue]THEN Month[/blue](Table.SomeDateField) = [blue]Month[/blue]([blue]CurrentDate[/blue]) [blue]ELSE[/blue] ...

Mike
---------------------------------------------------------------
"To be alive is to revel in the moments, in the sunrise and the sunset, in the sudden and brief episodes of love and adventure,
in the hours of companionship. It is, most of all, to never be paralyzed by your fears of a future that no one can foretell."
 
Crystal reports will allow you to set constants as default values , but not a dynamic content. This option is supported by some 3rd party viewers.

Viewer and Scheduler for Crystal reports and SSRS.
 
Thanks Mike and PeterDimitrov!

I just wanted to make sure that it cannot be done as peter said with out third party viewer, I can try Mike's solution, but the users here are very particular, when they say they want see the month, they mean it they will not take any workaround.

Thanks again!
 
Hopefully they are okay with default "text" and pressing enter to run the report, a workaround such as this is the only means I can think of to do what you are asking - essentially "trick" Crystal into calculating the dynamic value if the trigger is selected.

It always surprises me how often we report writers have to coerce CR to do what we want. [smile]

Cheers!

Mike
---------------------------------------------------------------
"To be alive is to revel in the moments, in the sunrise and the sunset, in the sudden and brief episodes of love and adventure,
in the hours of companionship. It is, most of all, to never be paralyzed by your fears of a future that no one can foretell."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top