Solved

Subreport with Multiple Variables

Posted on 2014-04-14
22
281 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
  • 10
  • 9
  • 3
22 Comments
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
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
Comment Utility
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 100

Expert Comment

by:mlmcc
Comment Utility
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
 

Author Comment

by:Mikeyman_01
Comment Utility
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 100

Accepted Solution

by:
mlmcc earned 250 total points
Comment Utility
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
Comment Utility
all 3 formulas are in the details of the subreport....they are not suppressed
0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
Does the formula display correctly in the subreport?

mlmcc
0
 

Author Comment

by:Mikeyman_01
Comment Utility
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 100

Expert Comment

by:mlmcc
Comment Utility
Can you post that formula?
Copy it and paste it here

mlmcc
0
 

Author Comment

by:Mikeyman_01
Comment Utility
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
Comment Utility
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
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
Comment Utility
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 100

Expert Comment

by:mlmcc
Comment Utility
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
Comment Utility
0
 
LVL 34

Assisted Solution

by:James0628
James0628 earned 250 total points
Comment Utility
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 100

Expert Comment

by:mlmcc
Comment Utility
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
Comment Utility
James... Mlmcc,

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

Expert Comment

by:mlmcc
Comment Utility
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 34

Expert Comment

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

 James
0
 

Author Comment

by:Mikeyman_01
Comment Utility
It would appear that the subreport was not set to grow
0
 
LVL 34

Expert Comment

by:James0628
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now