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

Change Group Options per Parameter 1

Status
Not open for further replies.

vb6novice

Programmer
Sep 23, 2002
288
US
My report has a grouping that is for a date. When I added the group, CR being smart like it is, knew the field is a date so it added the option in the Change Group Options dialog which says "The section will be printed" and below it a drop down menu list with the choices
for each day
for each week
for each two weeks
for each half month
for each month
and so on.

The date frequency for which the report should be printed actually depends on the date range selected by the report user.

Where would I put a formula to change that grouping option based on a report parameter and what might that formula be?

 
I'd do it with a single-letter value in the parameter, D for day, W for week etc.

Then code a formula field:
Code:
if @param = "D" then 
ToText(Datepart("yyyy", {your.date})) & "/" ToText(Datepart("y", {your.date}))
else if @param = "W" then 
ToText(Datepart("yyyy", {your.date})) & "/" & ToText(Datepart("w", {your.date}))
and so on. Use this field to group on.

Two-week and half-month will be tricky: I'd get the simple options working first and then try the others. For two-week, you might double and then truncats, so that 1 and 2 give the same answer, etc. Half-month might be based on day number within the month, but February would be special. Make those formula fields in their own right to get them OK.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Madawc,

You put me on the right track. I expanded your formula to include all my grouping options and I had to create an additional formula field for the group name so that when the user selects Months to group on he gets a month name, when he selects a quarter to group on, he gets '1st Quater', '2nd Quarter', etc.

It also took a little manipulation so that the dates would be in the right order (need the months in numeric order, not alphabetic). Also, if the user selected a date range of October 05 to January 06, the months must come up Oct 05, Nov 05, Dec 05, Jan 06, not based solely on the number of the month (otherwise you get Jan 06, then Oct, Nov, Dec 05).

Anyway, you got me going.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top