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

Selection Formula For Multiple Ranges !!

Status
Not open for further replies.

mzeezee

Programmer
Apr 16, 2011
5
PK
Dear Friends

I am using crystal reports 8.5 with MS Access database. I need to generate customer listing while accepting 6 paramerts from user (From/To Country, From/To Province, From/To City). Currently using following formula for selection:

if {?ContFr} = "ALL" then
if {?ProvFr} = "ALL" then
if {?CityFr} = "ALL" then
true
else
{QryCust.CityDesc} in {?CityFr} to {?CityTo}
else
if {?CityFr} = "ALL" then
{QryCust.ProvDesc} in {?ProvFr} to {?ProvTo}
else
{QryCust.ProvDesc} in {?ProvFr} to {?ProvTo} and
{QryCust.CityDesc} in {?CityFr} to {?CityTo}
else
if {?ProvFr} = "ALL" then
if {?CityFr} = "ALL" then
{QryCust.ContDesc} in {?ContFr} to {?ContTo}
else
{QryCust.ContDesc} in {?ContFr} to {?ContTo} and
{QryCust.CityDesc} in {?CityFr} to {?CityTo}
else
if {?CityFr} = "ALL" then
{QryCust.ContDesc} in {?ContFr} to {?ContTo} and
{QryCust.ProvDesc} in {?ProvFr} to {?ProvTo}
else
{QryCust.ContDesc} in {?ContFr} to {?ContTo} and
{QryCust.ProvDesc} in {?ProvFr} to {?ProvTo} and
{QryCust.CityDesc} in {?CityFr} to {?CityTo}

Just wanted to know if there is any better idea for the same? As I have to generate other reports where I would have to use 10 parameters (5 pairs of From and To) which could get very complicated.

Any advice would highly be appreciated :))

Best Regards

ZEE
 
Try breaking up the command into a number of separate Formula Fields, e.g.
Code:
 {?ContFr} = "ALL" and
{?ProvFr} = "ALL" and
{?CityFr} = "ALL"
Code:
 {?ContFr} = "ALL" and
{?ProvFr} = "ALL" and
{?CityFr} <> "ALL"
and {QryCust.CityDesc} in {?CityFr} to {?CityTo}
And so on for all your tests. These will return True or False - or blank if you hit a null, which you always need to think about. Try displaying them against unselected details. Then put them in the selection command, something like
Code:
@AllTrue or @CityFound





[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 11.5 with SQL and Windows XP [yinyang]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top