Link to home
Start Free TrialLog in
Avatar of -Darvin-
-Darvin-Flag for United States of America

asked on

Crystal Reports formlua to narrow scope current month + 2

My report shows open sales orders by month.  Currently it shows any sales orders in the system for any month no matter how far out it is.  Management is particularly interested in the value of open orders for the current month plus the next two months.  I haven't been able to narrow down this scope yet so that it can run automatically.  I know i could accomplish this with a parameter field but that isn't acceptable.  The report needs to dynamically changed based on current month.
if isnull({#January}) then '' else 'January = ' + CStr({#January},0) + 
if isnull({#February})then '' else ' | February = ' + CStr({#February},0) + 
if isnull({#March}) then '' else ' | March = ' + CStr({#March},0) + 
if isnull({#April}) then '' else ' | April = ' + CStr({#April},0) + 
if isnull({#May}) then '' else ' | May = ' + CStr({#May},0) + 
if isnull({#June}) then '' else ' | June = ' + CStr({#June},0) + 
if isnull({#July}) then '' else ' | July = ' + CStr({#July},0) + 
if isnull({#August}) then '' else ' | August = ' + CStr({#August},0) + 
if isnull({#September}) then '' else ' | September = ' + CStr({#September},0) + 
if isnull({#October}) then '' else ' | October = ' + CStr({#October},0) + 
if isnull({#November}) then '' else ' | November = ' + CStr({#November},0) + 
if isnull({#December}) then '' else ' | December = ' + CStr({#December},0)

Open in new window

Avatar of dougvarga
dougvarga
Flag of United States of America image

Sample select statement

{mydatabase.myfield} in Date(DatePart("YYYY",CurrentDate),DatePart("m",CurrentDate),1) to DateAdd("m",2,Date(DatePart("YYYY",CurrentDate),DatePart("m",CurrentDate),1))
ASKER CERTIFIED SOLUTION
Avatar of dougvarga
dougvarga
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of peter57r
peter57r
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of -Darvin-

ASKER

Thanks very much to both of you.  Both solutions work so I split the points.  Peter your solution worked as it is but only for two months (current and next month) I changed the +2 to +3 and it worked fine.  Both solutions are equally effective but I awarded dougvarga more because he was first and his worked as it was.  Hope that's fair.  Thanks again to both of you!