Author |
Message |
lazyme
Newbie
Joined: 07 Nov 2007
Online Status: Offline
Posts: 10
|
Topic: Surpress and Group Question Posted: 07 Nov 2007 at 2:27pm |
I have records that look like this:
[Sku] [Name] [On Hand] [Sold] [On Order] [Date]
1 A 100 5 20 1/1/2007
2 B 200 5 20 1/1/2007
3 C 150 10 35 1/1/2007
3 C 150 10 10 2/1/2007
4 C 130 10 15 1/1/2007
Since some Skus have more than 1 entries of orders coming in and I need to some them all, is it possible to make the report look like this:
[Sku] [Name] [On Hand] [Sold] [On Order] [Date]
1 A 100 5 20 1/1/2007
2 B 200 5 20 1/1/2007
3 C 150 10 35 1/1/2007
- - - - 10 1/1/2007
4 C 130 10 15 1/1/2007
Where the "-" part is emtpy. All I can do so far is surpass the SKU number as they are repeated.
Thanks in advance.
|
IP Logged |
|
BrianBischof
Admin Group
Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
|
Posted: 07 Nov 2007 at 11:54pm |
Well, this is an interesting question. It's going to require a formula to pull it off. You'll have to set a global variable that sets the last [Name], [On Hand], etc. printed. Then when a new record is printed, test to see if the fields match the previous variable's values. If so, print dashes. If not, print the current data and reset the variables. I would actually set a formula for each field and print the formula instead of the field.
Global StringVar LastName; if {Name} <> LastName Then {Name} Else "-"; LastName = {Name}
Repeat for all columns that need to be have this done.
|
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
|
IP Logged |
|
lazyme
Newbie
Joined: 07 Nov 2007
Online Status: Offline
Posts: 10
|
Posted: 08 Nov 2007 at 7:41am |
Thanks so much for you help.
Howeer, I am a beginner of Crystal Report, could you tell me exactly where I write the code?
Much appreciated!
Thanks
|
IP Logged |
|
BrianBischof
Admin Group
Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
|
Posted: 08 Nov 2007 at 12:55pm |
Ok. This might take a little time since you are new to CR. Create a new formula can call it something like 'Name Override'. Then enter the formula I posted earlier (making sure to use proper field names). Check the syntax to make sure everything works. Then save it and drag and drop it onto your report where the Name field should be printed. Try this out and get it working to see if it is what you were hoping for.
Also, I have three chapters dedicated to teaching you everything you need to know about writing formulas in CR if you want to learn more. Check out chapters 5-7 of my new book.
|
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
|
IP Logged |
|
lazyme
Newbie
Joined: 07 Nov 2007
Online Status: Offline
Posts: 10
|
Posted: 08 Nov 2007 at 1:32pm |
Hi, I created the formula under "Formula Fields" and the results for the field when the query is an is FALSE. This is the code I edited:
Global StringVar LastSku;
if {qry_Stock_Status.Sku} <> LastSku Then
{qry_Stock_Status.Sku}
Else
"-";
LastSku = {qry_Stock_Status.Sku}
|
IP Logged |
|
hilfy
Admin Group
Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
|
Posted: 08 Nov 2007 at 1:48pm |
Take the first and last lines out of your formula, along with the ';' after '"-"'. Your formula should then work.
-Dell
|
|
IP Logged |
|
BrianBischof
Admin Group
Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
|
Posted: 08 Nov 2007 at 1:49pm |
Ah I see. It's false b/c CR takes the LAST statement in the formula as your result. Thus, you are testing if LastSku is the same as {qyr_..} I missed this. I should have also uses ":=" in that statement. Let me tweak the formula so that it returns the string you want to print. Global StringVar LastSku;
StringVar ThisSku;
if {qry_Stock_Status.Sku} <> LastSku Then
ThisSku := {qry_Stock_Status.Sku}
Else
ThisSku := "-";
LastSku := {qry_Stock_Status.Sku};
//return the proper string ThisSku;
|
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
|
IP Logged |
|
lazyme
Newbie
Joined: 07 Nov 2007
Online Status: Offline
Posts: 10
|
Posted: 08 Nov 2007 at 2:10pm |
Great it works but I have a different problem. Only the Sku numbers are unique. Some Skus shares the same name and other info that need to be displayed. That said, when the [Names] are right after each other, the Sku number shows but not the [Names].
However, I can solve that myself now. I didn't realize I can use the formula fields to write detail programs like that.
Thanks for all your help!!
Edited by lazyme - 08 Nov 2007 at 2:11pm
|
IP Logged |
|
hilfy
Admin Group
Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
|
Posted: 08 Nov 2007 at 2:15pm |
I didn't read through the code well enough before to see what the variable was doing....
Another way to do this without a variable would be:
if {qry_Stock_Status.SKU} = previous({qry_Stock_Status.SKU}) then
"-"
else
{qry_Stock_Status.SKU}
|
|
IP Logged |
|
BrianBischof
Admin Group
Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
|
Posted: 08 Nov 2007 at 3:27pm |
Ah! Much better.
|
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
|
IP Logged |
|
|