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

conditioning data with if then else

Status
Not open for further replies.

char473

Technical User
Dec 22, 2006
7
US
Hi, this is my first posting...be gentle.

I'm having difficulties getting my report to select from the multiple details records from a secondary table. Here's an example of the table layout

table1 table2
ID1 detaila
detailb
detailc

Now, the selection of data from table2 is contingent upon the value found in a corresponding column

table2
column1 detaila detailb detailc
column2 red blue green

if table2.column2 = red then
table2.column1 else
if table2.column2 = blue then
table2.column1 else
if table2.column2 = green then
table2.column1
else ""

My problem is getting the code to print a preferrence of the above. In most cases only one of the above would be true but in several cases two of the above is true and I want the first condition to print.

I've tried setting up variables to capture this data and setting those to null when false. I've also tried having each of these conditions evaluated one after the other. Bottom line...still ain't working.

Any suggestions?

 
Hi,
Can you explain further this statement:
char473 said:
In most cases only one of the above would be true but in several cases two of the above is true and I want the first condition to print.

How can table2.column2 in the same record be more than 1 value? ( red or green or blue)





[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
I need to work on my examples...hopefully without going into the business details here's an example;

Let's say a need a report of all the cars in stock and the colors of those by customer preference. The customer prefers blue if not then red if not then green

I only need on line of information per car and if it comes in blue then print blue if not, but does come in red then print red, if not red, but does come in green then green else blank.

The approach I was favoring was
1) In group header "car" section
to set a variable in group header for car = ""
stringvar coloravailable = ""
2) In detail section set up three formulas

formula1
if column2.color = blue then
stringvar colorchoice := column2.colorname

formula2
evaluate after formula1;
if stringvar colorchoice = "" and column2.color = red then
stringvar colorchoice := column2.colorname

evaluate after formula2;
if stringvar colorchoice = "" and column2.color = green then
stringvar colorchoice := column2.colorname

3) after group of cars print colorchoice

I hope this makes sense
 
Hi,
If I understand correctly, each car's record includes its color and only 1 color per car (lets not go down the two-tone route [wink])

Your object is to find a car in stock that matches the customer's choice and, further,the customer may specify 3 colors in order of preference.

Is that basically it?



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
HI,
Before I begin, I apologize for my rudeness, I was place on other projects. I realllly appreciate your help.

Turkbear your reallll close.

Here's an example of the data

CarA Blue CarB Red CarC Green CarD White
CarA Red CarB Green CarC White
CarA Green

The customer has chosen the color choices Blue, Red, and Green respectively.

The report would look as follows;
CarA Blue
CarB Red
CarC Green
CarD (null)


 
Do you group by car? If not, do so. Suppress details and show just the group header or footer.

You have several values and you want to give them a priority. This can be done using a formula field that attaches some value of your chooising, e.g.
Code:
if {car} = "blue" 
then "1) " & {car}
else
if {car} = "red" 
then "2) " & {car}
else...
You can then use Summary Totals to get the minimum - blue if blue occurs, red if not, etc. Use mid to get back to the orignal value for display.

Or you could sort using the formula field and then use the original value in the header.

If you're not already familiar with Crystal totals, see FAQ767-6524.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top