Solved

Subreport with Multiple Variables

Posted on 2014-04-14
22
288 Views
Last Modified: 2014-05-06
Hi Experts,

I have data that reads the following with Details of a SubReport...

LOC ST 03895
SO 0000000110295042
SO Moab
many more lines

I have created a formula within the subreport called @SalesOrderCommentLines


Shared StringVar CustomerNumber;
If {Documents/Document/DetailData/DetailLine/Comment.DetCommentDescript}[1 to 30] LIKE  "SO 000*" then
CustomerNumber:= {Documents/Document/DetailData/DetailLine/Comment.DetCommentDescript}[4 to 30];



Shared StringVar CustomerOrderNumber;
If {Documents/Document/DetailData/DetailLine/Comment.DetCommentDescript}[1 to 30] LIKE  "LOC*" then
CustomerOrderNumber:= {Documents/Document/DetailData/DetailLine/Comment.DetCommentDescript}[8 to 30];



Shared StringVar ShipToName;
If {Documents/Document/DetailData/DetailLine/Comment.DetCommentDescript} [1 to 30] LIKE "*Mo*" then
ShipToName:={Documents/Document/DetailData/DetailLine/Comment.DetCommentDescript}[1 to 30];

I Placed this subreport in the ReportHeader of my Main Report..

I am trying to call each of these variable to the PageHeader a....
@SharedCustomer, @SharedCustomerOrderNumber, @ShipToName

I can grab the first 2 listed in this formula, but no matter what I try, the third does not come...@ShipToName

Hopefully this makes sense
0
Comment
Question by:Mikeyman_01
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 10
  • 9
  • 3
22 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 39999376
Are you sure there is data that meets the criteria?

Is the subreport visible?
If not can you make it visible?
Does it show the values you expect?

As best I can tell you are using the variables correctly.

The only thing I do differently is add WhilePrintigRecords; as the first line of each formula.  It is not required but it serves to remind me when the formula is evaluated.  Formulas with Shared variables are evaluated in the Printing Records pass.

mlmcc
0
 

Author Comment

by:Mikeyman_01
ID: 39999400
Actual Lines that I am trying to read from Subreport to MainReport

If it wasn't visible why would the other 2 variable show on the Main Report.. I have included a screen shot of the system where the lines exist.. Eventually all of these lines need to be shared from a SubReport to the Main Report
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 39999423
Just trying to verify a record with Mo in it exists in the subreport data.

What is the formula to display that one?

mlmcc
0
[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

 

Author Comment

by:Mikeyman_01
ID: 39999571
The subreport variable is this

Shared StringVar ShipToName;
If {Documents/Document/DetailData/DetailLine/Comment.DetCommentDescript} [1 to 30] LIKE "*Mo*" then
ShipToName:={Documents/Document/DetailData/DetailLine/Comment.DetCommentDescript}[1 to 30];

the formula to call into the Main Report is this

@SharedShipToName

WhilePrintingRecords;
Shared StringVar ShipToName:=ShipToName;
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 250 total points
ID: 39999872
There is no need for the assignment in the display formula.  It shouldn't hurt but you can use

WhilePrintingRecords;
Shared StringVar ShipToName;
ShipToName

I assume all 3 formulas are in the details of the subreport?
Are they suppressed?

mlmcc
0
 

Author Comment

by:Mikeyman_01
ID: 40000000
all 3 formulas are in the details of the subreport....they are not suppressed
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 40000122
Does the formula display correctly in the subreport?

mlmcc
0
 

Author Comment

by:Mikeyman_01
ID: 40000178
Not really sure how to answer that...The subreport has 20 Rows as Values within the Details...I have 1 formula that is at the Detail level of the Subreport...This 1 formula has 3 variables...the First 3 are set to show in the PageHeader a of the Main Report..but the First 2 only show..

The 3rd variable shows nothing...

The SubReport itself at the top of the Main Report shows the first Variable.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 40000197
Can you post that formula?
Copy it and paste it here

mlmcc
0
 

Author Comment

by:Mikeyman_01
ID: 40000224
Subreport Formula..for the portion related to the record showing in ReportHeader
and then showing in the PageHeader a



Shared StringVar CustomerOrderNumber;
If {Documents/Document/DetailData/DetailLine/Comment.DetCommentDescript}[1 to 30] LIKE  "LOC*" then
CustomerOrderNumber:= {Documents/Document/DetailData/DetailLine/Comment.DetCommentDescript}[8 to 30];



---------------------------------------------------------

MainReport Formula.. this is showing in the PageHeader a of the Main Report

@SharedShipToName

WhilePrintingRecords;
Shared StringVar ShipToName:=ShipToName;
0
 

Author Comment

by:Mikeyman_01
ID: 40000250
Sorry this is the one that is showing ...

@SharedCustomerOrderNumber

WhilePrintingRecords;
Shared StringVar CustomerOrderNumber:=CustomerOrderNumber;

this one is not showing

@SharedShipToName

WhilePrintingRecords;
Shared StringVar ShipToName:=ShipToName;
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 40000343
DO you have 1 formula in the subreport that sets all the shared variables?
If so can you post the full formula?

There may be some reason that specific case isn't being handled correctly.

mlmcc
0
 

Author Comment

by:Mikeyman_01
ID: 40000418
i did..

@SharedSalesOrderCommentLines


Shared StringVar CustomerNumber;
If {Documents/Document/DetailData/DetailLine/Comment.DetCommentDescript}[1 to 30] LIKE  "SO 000*" then
CustomerNumber:= {Documents/Document/DetailData/DetailLine/Comment.DetCommentDescript}[4 to 30];



Shared StringVar CustomerOrderNumber;
If {Documents/Document/DetailData/DetailLine/Comment.DetCommentDescript}[1 to 30] LIKE  "LOC*" then
CustomerOrderNumber:= {Documents/Document/DetailData/DetailLine/Comment.DetCommentDescript}[8 to 30];



Shared StringVar ShipToName;
If {Documents/Document/DetailData/DetailLine/Comment.DetCommentDescript} [1 to 30] LIKE "*Mo*" then
ShipToName:={Documents/Document/DetailData/DetailLine/Comment.DetCommentDescript}[1 to 30];
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 40000778
If that is a true cut and paste from the formula editor, I don't see any reason why it doesn't work.

DO you have a formula in the main report report header to declare the shared variables

WHilePrintingRecords;
Shared StringVar ShipToName;
Shared StringVar CustomerOrderNumber;
Shared StringVar CustomerNumber;
""

I would write the subreport formula differently.  It shouldn't matter
WHilePrintingRecords;
Shared StringVar ShipToName;
Shared StringVar CustomerOrderNumber;
Shared StringVar CustomerNumber;
If  Left({Documents/Document/DetailData/DetailLine/Comment.DetCommentDescript},6) =   "SO 000" then
    CustomerNumber:= {Documents/Document/DetailData/DetailLine/Comment.DetCommentDescript}[4 to 30]
Else If  Left({Documents/Document/DetailData/DetailLine/Comment.DetCommentDescript},3) =   "LOC""  THEN
    CustomerOrderNumber:= {Documents/Document/DetailData/DetailLine/Comment.DetCommentDescript}[8 to 30]
Else If InStr({Documents/Document/DetailData/DetailLine/Comment.DetCommentDescript},"Mo") >0 THEN
    ShipToName:={Documents/Document/DetailData/DetailLine/Comment.DetCommentDescript}[1 to 30]; 

Open in new window


Can you upload the report file?
I don't need any data in it.  Maybe I'll see something then

mlmcc
0
 

Author Comment

by:Mikeyman_01
ID: 40000796
0
 
LVL 35

Assisted Solution

by:James0628
James0628 earned 250 total points
ID: 40001220
FWIW, I looked at the report, and nothing obvious jumped out at me.

 Try changing the end of your subreport formula to:

If {Documents/Document/DetailData/DetailLine/Comment.DetCommentDescript} [1 to 30] LIKE "*Mo*" then
ShipToName:={Documents/Document/DetailData/DetailLine/Comment.DetCommentDescript}[1 to 30]
else
ShipToName:="test";

Open in new window


 If you see "test" in the main report, then you know that the variable is working, and the problem is something in your test, or in the data.

 James
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 40001464
I don't see anything particularly wrong with the formula either.

Why do you have the extra tables in the subreport?
You are only using data from one of them.
You might try deleting them from the report.
Crystal can do some strange things when it has extra tables particularly since they aren't linked together.

Also you might try setting the subreport so it can grow just to see what it produces.  If you don't want it to show anything then the formula in it can be changed to end with "" which will display nothing each time.  You can then also suppress blank sections ini the subreport and suppress a blank subreport.

mlmcc
0
 

Author Comment

by:Mikeyman_01
ID: 40004386
James... Mlmcc,

nothing shows up...even the "test" that James presented...weird
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 40004480
You have the subreport in the report header.

Does anything show in the report header for the subreport?

If not, is the subreport allowed to grow?

mlmcc
0
 
LVL 35

Expert Comment

by:James0628
ID: 40017081
I'm curious.  Did you actually figure out what was wrong?

 James
0
 

Author Comment

by:Mikeyman_01
ID: 40043299
It would appear that the subreport was not set to grow
0
 
LVL 35

Expert Comment

by:James0628
ID: 40044247
Ah.  mlmcc asked about that in his last post.  If that was what prompted you to check, then that post probably should have been accepted as the solution.

 IAC, thanks for letting us know.

 James
0

Featured Post

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question