I am assuming you made a typo in your example and it was supposed to be
454 21456 5002100000 5002100000 s-4567
454 21456 5002110000 5002110000 s-4567
454 21566 5002300000 5002300000 s-4567
433 24567 5002390000 5002390000 s-4899
To reflect what you have described in your second post.
The structure # is coming off the database but I want to change the structure # based on the change of the sixth digit of the structure ID and looking for a formula or function in order todo that
You are retrieving your structure data from the DB. Crystal doesn't change the data on your DB.
You can remove the structure # table field from your report and instead replace it with the formula that you will define that will determine what the # should be.
A formula can change based on the results from the DB; a table field cannot.
Based on what you have described, the logic would be as follows:
-assign the structure# to a variable (data from the table)
-check the sixth digit of your structure ID
-if the digit is 0 or 1, display the variable ("the same as the table")
-else, assign a new value to the variable and display that. (this handles the non 0 or 1 case.)
I don't know how you are choosing to assign values if it is a different structure, so that may involve several things if it's really complex. A really simple implementation would be
local numbervar temp := {table.structure#}; //store original value
local stringvar digit := {table.structureID}[6]; //sixth character
if digit <> 0 and digit <> 1 then //not 0 or 1
temp := 42 //some random new value I picked to display
temp; //display the value
As I can't imagine what everything looks like because I'm not too experienced with DB's, I can only give you the general algorithm that should produce what you are looking for.
As a general rule, if you want to change data, use a formula and put that on the report in place of the field.
Edited by Keikoku - 01 Mar 2011 at 3:37am