|
-
Apr 15th, 2004, 09:05 AM
#1
Thread Starter
Addicted Member
CR 8.5: Help With Formula
HI
I have 5 Fields in the DB:
CON_AFM.AFM_DIABETES, CON_AFM.AFM_TENSION, CON_AFM.AFM_STRESS, CON_AFM.AFM_HIV and CON_AFM.AFM_TIROIDE
every field can have the value 1 or 0. Now i want to look for every field that have the value 1 and change to a string.
if CON_AFM.AFM_DIABETES value is 1 then the string to show is "Diabetes"
if CON_AFM.AFM_TENSION value is 1 then the string to show is "Hipertension"
if CON_AFM.AFM_STRESS value is 1 then the string to show is "Stress"
if CON_AFM.AFM_HIV value is 1 then the string to show is "HIV"
if CON_AFM.AFM_TIROIDE value is 1 then the string to show is "Tiroides"
But if the value is 0 i don´t show a string
Example:
DB Fields with Values
CON_AFM.AFM_DIABETES 1
CON_AFM.AFM_TENSION 1
CON_AFM.AFM_STRESS 0
CON_AFM.AFM_HIV 0
CON_AFM.AFM_TIROIDE 1
The formula must return a string like
"Diabetes, Hipertension, Tiroides"
-
Apr 15th, 2004, 01:41 PM
#2
Hyperactive Member
There might be a better way but you can try something like creating a formula and using the formula editor, have something like this:
VB Code:
'--CRYSTAL SYNTAX BELOW
stringVar strTEST;
if {RAMain.VPApproved}=true then
strTEST := "VP"
else strTEST := "";
if {RAMain.CRApproved}=True then
strTEST := strTEST + ",CR"
else strTEST := strTEST;
if {RAMain.Void}=true then
strTEST := strTEST + ",VO"
else strTEST := strTEST;
if left(strTEST,1) ="," then 'this removes a comma if the first check is false
strTEST := MID(strTEST,2,LEN(strTEST)-1);
-
Apr 15th, 2004, 06:13 PM
#3
Thread Starter
Addicted Member
Thanks Arprince for your code works perfect.
Here is the code if anybody need for help
VB Code:
// crystal syntax
stringVar STR;
if {CON_AFM.AFM_DIABETES} = 1 then STR = "Diabetes" else STR = "";
if {CON_AFM.AFM_TENSION} = 1 then STR := STR + ", Hipertensión" else STR := STR;
if {CON_AFM.AFM_STRESS} = 1 then STR := STR + ", Stress" else STR := STR;
if {CON_AFM.AFM_HIV} = 1 then STR := STR + ", HIV" else STR := STR;
if {CON_AFM.AFM_TIROIDE} = 1 then STR := STR + ", Tiroides" else STR := STR;
// Esto elimina la coma si el primero es falso
if left(STR,1) ="," then STR := MID(STR,2,LEN(STR)-1);
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|