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

Newbie Needs Basic If then else...Formula Assistance 1

Status
Not open for further replies.

pappion

MIS
Feb 12, 2003
27
0
0
US
I am working with a report which contains a field called requirements. This field lists the following
pedicure: string (1)
manicure string (1)
Hair Care string (1)

The 1 string is Y or N

Not sure should an if then else... statement be used here?

Any assistance is greatly appreciated.


 
A little more information...

Are these three fields? Or one field with three chars? What do you want to do with them?

If you can give a short example of the data as it comes from the DB and what kind of output you are looking for I am sure someone here can assist you.

Lisa
 
Do you mean to say that you have a table called Requirements, which contains 3 fields?

If you're trying to sum them, try creating a formula from each containing something like:

if (Requirements.pedicure} = "Y" then
1
else
0

Create 2 more formulas for the other 2 fields (manicure,
Hair Care)

Drop the fields in the details, right click them and select insert summary->Sum

You'll get totals.

-k
 
Here's what I am trying to accomplish:

Fields in Requirements table are:

Client ID
Manicure
Pedicure
Hair Care


If requirements.pedicure = "Y" then Pedicure
I want the requirement(s) to print per Client. These fields are Yes and No.

Columns in report look like this
ClientID First Name Last Name Requirements

Thanks for your responses and help.

 
Create a formula called Requirements like :

StringVar TempPedicure := "";
StringVar TempManicure := "";
StringVar TempHairCare := "";

If requirements.pedicure = "Y" then TempPedicure := "Pedicure";
If requirements.manicure = "Y" then (if TempPedicure = "" then TempManicure := "Manicure" else TempManicure := ", Manicure");
If requirements.haircare = "Y" then (if TempPedicure = "" and TempManicure = "" then TempHairCare := "Hair Care" else TempHairCare := ", Hair Care");
TempPedicure&TempManicure&TempHairCare;

Does this help?


Reebo
Scotland (Sunny with a Smile)
 
I'm clear on what you want to do but not so clear on the data that's in the three fields you've described. In the actual database does the Manicure, Pedicure, and Hair Care fields have 1s and 0s or does each field actually have "string (1)" listed in it?

If it is an actual Boolean field, (1s and 0s) then you can do a couple of things among others;

Make a formula called {@Hygiene} and use this code;

IF {Table.Manicure}
THEN 'Manicure'
ELSE IF {Table.Pedicure}
THEN 'Pedicure'
ELSE IF {Table.Hair Care}
THEN 'Hair Care'


The above code only assumes that one of the three will be True/Yes. If there are multiples that are true then you have to code for that.

The other thing you can do if the three database fields in question are Boolean, (true/false, Yes/No, 1/0), is to make text column headers with the respective names of the fields and then place the fields under their respective header. You can then format the Boolean field to display a "Yes" or "No".


 
OK, now I think I understand it, you original post said that you had a field called requirements which lists things.

Place the Client ID, First Name, Last Name in the Details and create the following formulas (Insert->Field Object->Right click formulas and select New):

Create 3 formulas:

@pedicure
IF {Requirements.Pedicure} = "Y" then
'Pedicure'

@manicure
IF {Requirements.Manicure} = "Y" then
' Manicure'

@hair care
IF {Requirements.Haircare} = "Y" then
' Hair Care'

Drop a text box (Insert Text Object) into the details, and then place these 3 fields into the text box, make sure that you observe the spacing in each of the 3 formulas to allow for proper output.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top