The code you have written to handle the null value is correct, as your results indicate that it works and does display a "-".
The "previous" record becomes a problem.
Consider the following:
1: you have two records. The second record has no Struct#. You can use previous({table.struct#}) to get the previous one. That should work.
2: Suppose you have three records. The second and third records do not have struct #. The second record can be handled the same way as before, but the third one will pose issues now because the previous record does not have a struct#!
So then the statement "it must be the previous record" I'm guessing would be inaccurate, and it should be more like "any null values should have the same struct# as the most recent non-null struct#"
This becomes a little tricky if you are aiming for performance, and I can't think of any good solutions to deal with it.
One option is to have a global variable defined in another formula that will keep track of the struct# as you're reading records (using WhileReadingRecords keyword). This global variable will say
if struct# is not null, then store it
else, ignore it
This will basically retain the most recent non-null struct# that you have seen.
Then, you can say something like
if isnull({structure.struct#}) then
temp := the_global_variable
else
{structure.struct#}
Here, you know that the global variable stores the value of the "previous" non-null struct#, so even if you have 20 records with null struct#, you will replace them with the "previous" non-null number.
Note that I say "previous" because it is not the crystal interpretation of `previous`
Now here is another situation
Suppose you assign a new struct# to your most recent non-null record. Would the subsequent records take on this new struct#? If so, then you must make sure that the global variable is updated to reflect this change, because it would store the default table-provided value which is NOT the new #.
Edited by Keikoku - 02 Mar 2011 at 4:52am