Ryan Rood
asked on
Crystal Reports Formula Editor
Good morning,
I am modifying a Crystal Report and having some issues. Essentially I need to add a filter to see if a string of text exists in the record and then omit if it does. Here is the current code. I need to add something like this
IF InStr({OrderHeader.ManualDescription}, "Trim 1") THEN 0
I have noted where I believe the new data chunk should go (hopefully). Long story short - if the OrderHeader.ManualDescription is going to be used I need to check it first for "Trim 1" and omit it.
Thank you in advance for any guidance here.
Ryan
I am modifying a Crystal Report and having some issues. Essentially I need to add a filter to see if a string of text exists in the record and then omit if it does. Here is the current code. I need to add something like this
IF InStr({OrderHeader.ManualDescription}, "Trim 1") THEN 0
I have noted where I believe the new data chunk should go (hopefully). Long story short - if the OrderHeader.ManualDescription is going to be used I need to check it first for "Trim 1" and omit it.
Shared numbervar oldLinkedToLineID;
Shared numbervar curLinkedToLineID;
stringvar strIndent := "";
If oldLinkedToLineID = curLinkedToLineID and curLinkedToLineID > 0 Then strIndent := " -> ";
If {OrderHeader.LineType} = 1 Then //Product
(
// POTENTIAL NEW CODE INSERTION HERE?
If IsNull({OrderHeader.ManualDescription}) Then
strIndent + {OrderHeader.Description}
Else
strIndent + {OrderHeader.ManualDescription}
)
Else If {OrderHeader.LineType} = 2 Then // Profile
(
strIndent + {OrderHeader.ManualDescription}
)
Else
(
If IsNull({OrderHeader.ManualDescription}) Then
strIndent + {OrderHeader.ManualCode}
Else
// POTENTIAL NEW CODE INSERTION HERE?
strIndent + {OrderHeader.ManualDescription}
)
Thank you in advance for any guidance here.
Ryan
ASKER
Thank you for the reply James. I don't think I have included enough detail in my question. My knowledge of Crystal Reports is limited to small modifications so I apologize if I am not providing the appropriate level of detail.
With this document we are already splitting it to print pages by sales order section. So what would normally be a 2 page document is being split based on these special descriptions like "Trim 1".
The actual goal of this is to suppress this entire page. Perhaps my approach is the wrong one and I should be adding code to the section expert to suppress the section if ({OrderHeader.ManualDescription}, "Trim 1") = 0?
Thanks,
Ryan
With this document we are already splitting it to print pages by sales order section. So what would normally be a 2 page document is being split based on these special descriptions like "Trim 1".
The actual goal of this is to suppress this entire page. Perhaps my approach is the wrong one and I should be adding code to the section expert to suppress the section if ({OrderHeader.ManualDescription}, "Trim 1") = 0?
Thanks,
Ryan
Is "Trim 1" a string somewhere in OrderHeader.ManualDescription (eg. "This is a description - Trim 1"), or is "Trim 1" the only thing in the field?
If it's the only thing in the field, the test can just be {OrderHeader.ManualDescription} = "Trim 1" (or {OrderHeader.ManualDescription} <> "Trim 1", depending on how you're using it). If the field could be null, you'll probably still need an IsNull test first.
But the question is, where do you do that test?
You said that you're "splitting it to print pages by sales order section". Exactly how are you doing that? I think that's the key here.
Also, are you doing any summaries, like for weight or qty? You said that you want to "suppress" the "Trim 1" pages. If you're doing any summaries, should the items on those pages still be included in those totals? Or are they something like extra/duplicate items that you just don't want included in the report in any way?
If it's the latter, maybe you need to look at the record selection (to just exclude those items from the report completely), rather than trying to suppress that page.
James
If it's the only thing in the field, the test can just be {OrderHeader.ManualDescription} = "Trim 1" (or {OrderHeader.ManualDescription} <> "Trim 1", depending on how you're using it). If the field could be null, you'll probably still need an IsNull test first.
But the question is, where do you do that test?
You said that you're "splitting it to print pages by sales order section". Exactly how are you doing that? I think that's the key here.
Also, are you doing any summaries, like for weight or qty? You said that you want to "suppress" the "Trim 1" pages. If you're doing any summaries, should the items on those pages still be included in those totals? Or are they something like extra/duplicate items that you just don't want included in the report in any way?
If it's the latter, maybe you need to look at the record selection (to just exclude those items from the report completely), rather than trying to suppress that page.
James
If you are trying for page suppression a couple of other questions arise. Can the Trim 1 be on any detail line on the page? If so it will be difficult to suppress the page since the page may be already rendered before you find the record?
In your example, do you want to suppress that whole page of the report?
mlmcc
In your example, do you want to suppress that whole page of the report?
mlmcc
ASKER
James0628: "Trim 1" is the only text in the field. I tried to add the suppression to the group header which did not work (both examples). Not doing any summaries. I believe it is splitting the page on a "order" section start (Trim 1) for example.
Mike McCracken: It should always be the first record on the page since it is splitting on this field. The problem is I don't know this level of crystal or anywhere close to it.
I appreciate the help - but I think this one is over my head until I can do some training on Crystal Reports or my developer comes back.
Mike McCracken: It should always be the first record on the page since it is splitting on this field. The problem is I don't know this level of crystal or anywhere close to it.
I appreciate the help - but I think this one is over my head until I can do some training on Crystal Reports or my developer comes back.
Can you upload the report file?
mlmcc
mlmcc
If the report was actually grouped on OrderHeader.ManualDescription, you could use Group Selection to exclude the "Trim 1" group.
But if "Trim 1" is just a line in the order and you don't want to see that line, or the ones after it, on the report, that's trickier. Supressing/Excluding the "Trim 1" line would be easy. The tricky part is suppressing the lines after that, based on the value ("Trim 1") in a previous line.
If you could upload the report file, as Mike suggested, that would make things a lot easier.
James
But if "Trim 1" is just a line in the order and you don't want to see that line, or the ones after it, on the report, that's trickier. Supressing/Excluding the "Trim 1" line would be easy. The tricky part is suppressing the lines after that, based on the value ("Trim 1") in a previous line.
If you could upload the report file, as Mike suggested, that would make things a lot easier.
James
ASKER
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
If OrderHeader.ManualDescription includes "Trim 1", do you want to output strIndent by itself (without OrderHeader.ManualDescription), or do you want to output an empty string (""), or something else?
I think that the code below will work, as long as you don't want to do something else that's more complicated. I'm just posting that If block:
Open in new window
You had suggested putting the new test before the IsNull test, but IsNull has to come first. If CR encounters a null value in a formula anywhere but in an IsNull test, it will just stop evaluating that formula at that point. So if a field could contain nulls, you always have to test for that first.
James