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

If ... = true ... then Problem, Crystal 8.5

Status
Not open for further replies.

wesleycrusher

Technical User
Sep 30, 2003
61
US
Greetings. I am new to Crystal and, at the risk of sounding too new, have a problem with an "if then" statement. I'm using Crystal 8.5 to create a directory of products from our DB. Certain products either have a feature or don't, hence the 0/false or 1/true stored in the DB. I currently have the report showing a 0 if it doesn't have the feature(s) and 1 if it does, the default. I want to change this to say "U" if it does and a blank char or space if it doesn't. What would the code be to do this in Crystal and do I need a void print or something similar?
 
This is what you are looking for, paste it into the formula editor and replace the {Table.Field} with your field.


IF {Table.Field} = 1 THEN "U" ELSE " "

 
That is exactly what I have been using but it doesn't work. I pasted the code into Crystal using the appropriate {Table.Field} and it gives me a "String is Required Here" error. I have encountered this as well as "the result must be a boolean" message (or something like that). My only guess is I am trying to do this is in the wrong place in the program, I: right click -> format field -> common tab -> and enter the formule in the top-most formula button on the right, for object visibility. Is this even correct?
 
What type of field is the {Table.Field} in the source data, is it stored as a number or a string?
 
Try the following:

IF {Table.Field} = "1" THEN "U" ELSE " "

Note that {table.field} is a string.


Software Sales, Training, Implementation and Support for Exact Macola, eSynergy, and Crystal Reports
 
If you went to Insert/Field object and chose formula and pasted this formula:
IF {Table.Field} = 1 THEN "U" ELSE " "

and got the "string required..." it means that the {table.field} is a string, change the formula to:
IF {Table.Field} = "1" THEN "U" ELSE " "

The boolean required.... Was you formula something like
IF {Table.Field} = 1 THEN true ELSE " " ?

Crystal doesn't allow different types of output types for If - then's. You could use IF {Table.Field} = 1 THEN "True" ELSE " " so that both results are a string.









Mike
 
Thank you, everyone! It was indeed that I was placing the code in the wrong place. I should have used a formula field to accomplish what I needed rather than the method I was employing. It appears that instead of creating a formula to print what I desired, I was tring to transform the DB contents into something else right in its own field. Again, thanks for the quick responses everyoen. It was very important to me to figure this out since I will be doing this exact thing for several items and you all came through!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top