cancel
Showing results for 
Search instead for 
Did you mean: 

Creating a sub report with a formular based on records from a SQL Query

12-30-2019 4:43 PM
375 views 1 comments
0 Likes
SAP Managed Tags
Subscribe

We have a Crystal Report that is used as a Purchase Order Document and prints when the Purchase order is entered into the system. Because we have Government contracts, the user must remember to include a line of text in the notes section if it falls under a certain Contract type. Well they sometimes forget and we get fined. My idea was to create a sub report that would automatically add the text if the criteria was met. This is what I have done but does not seem to work.

I inserted a sub report Named "Add_Me" into the main report. Using the Wizard I added a "Command" from one of my database connections. The SQL I used is as follows

SELECT Distinct dbo.PorMasterDetail.PurchaseOrder, dbo.PorMasterDetail.MJob, dbo.[WipMaster+].Job, dbo.[CusSorMaster+].SalesOrder, dbo.[CusSorMaster+].DodContract
FROM
dbo.[CusSorMaster+]
INNER JOIN dbo.[WipMaster+] ON dbo.[CusSorMaster+].SalesOrder = dbo.[WipMaster+].IncomingSalesOrder and [CusSorMaster+].InvoiceNumber = ''
INNER JOIN dbo.PorMasterDetail ON dbo.[WipMaster+].Job = dbo.PorMasterDetail.MJob
WHERE dbo.[CusSorMaster+].DodContract = 'FA8203-27-D-1226'

There are other records in that field but I only care about the ones that contain 'FA8203-27-D-1226'

From my Field Explorer I have inserted from the Database Field "Command" the DoDContract field.
I chose to Hide it. I then created a formula named AddTextIf that says...

If {Command.DodContract} = 'FA8203-27-D-1226' Then "A Bunch Of Text Here" Else "

Here is my problem....
The PurchaseOder from Command must equal the PurchaseOrder in the main document which in the main document the field is from an XML document represented as Documents/Document/HeaderData as shown here.

I linked them like this...
Fields to link to Documents/Document/Headerdata.PurchaseOrder to Command.PurchaseOrder

When I print the report nothing shows up in the field that has the sub report.

0 Likes

Accepted Solutions (0)

Answers (1)

Answers (1)

DellSC
Active Contributor
0 Likes

If the text you're using doesn't require any data from the command, you don't need to use a subreport.

Here's what I would do instead:

1. Use the section where you currently have your subreport.

2. Put the text that you want in the section.

3. Go to the Section Expert for the section where the text is.

4. Click on the formula button to the right of the "Suppress" checkbox. DO NOT check the checkbox!

5. Enter something like this formula:

{Command.DodContract} <> 'FA8203-27-D-1226'

This will suppress the section if the contract number is no the one you're interested in.

-Dell