Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Selection Formula For Multiple Ranges !! Post Reply Post New Topic
Author Message
mzeezee
Newbie
Newbie


Joined: 02 May 2011
Online Status: Offline
Posts: 1
Quote mzeezee Replybullet Topic: Selection Formula For Multiple Ranges !!
     Posted: 02 May 2011 at 12:25pm

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

IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 03 May 2011 at 3:30am
what if you broke up the statement to something like:
local booleanvar country;
local booleanvar city;
local booleanvar province;
 
  if {?CityFr} = "ALL" OR  {QryCust.ContDesc} in {?ContFr} to {?ContTo} then city:=true;
do the same for the province and the country then as a last line:
city and province and country
 
this will only include the record if all 3 variables have a value of true...which is what I think you are after, and will be much easier to maintain.
 
At the very least, it is an idea.
 
HTH
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum