Page 1 of 2

Invoice with supporting pages?

Posted: Sat Dec 29, 2018 8:19 pm
by TestBoy
I am going to try my best to explain this...

For each record in a databand I need a page at the end. Let's say I have 50 invoice lines...

First n pages depending on whether or not they fit....

<databand>
record 1
record 2
record 3
record 4
record 5
.....
record 50
</databand>

New pages.....

<support for record 1>
<support for record 2>
....
<support for record 50>

And I need it to be conditional. I may not need the additional pages.
And the support pages are a subreport.

Basically, I need an invoice on the first n pages and if whoever is getting the invoice requires support I need to be able to add that support for each record to the end.

I tried adding two databands, one with the lines and various combinations of new page before/after and I end up with various weird looking results like the subreports spanning pages, the first one missing, the last one missing, the footer being printed in the header (not making that up) but nothing that even resembles what I need.

Re: Invoice with supporting pages?

Posted: Sat Dec 29, 2018 10:28 pm
by TestBoy
Okay, so I found out I can add a page and this does what I want.
The invoice portion gets data from a business object - and that works.

The second page has another databand that has the subreport in it.
That subreport was added from a file and that report requires two parameters.
When I add that I pick the subreport file and add the two parameters.
The name is the same as the name of the variables in the subreport and the expression points to the field in the business object.

The subreports don't display any data. I don't think it's even hitting the SQL server to get the data.
The variables are used in the SQL query that's in the subreport.

I don't know if I am doing this right either but I got a little further.

See attached.... what am I doing wrong?

Re: Invoice with supporting pages?

Posted: Mon Dec 31, 2018 8:44 am
by Lech Kulikowski
Hello,

To use Parameters in SubReports, you should use the expression:
{this["Var"]}

add a variable with the same name is not needed.

Thank you.

Re: Invoice with supporting pages?

Posted: Mon Dec 31, 2018 6:27 pm
by TestBoy
You have me at a loss.
The subreport needs the parameter.... so...?

Where does this line of code go then?
How does that populate the parameter in the subreport?
Is "Var" the name of the parameter in the suibreport?

I need a lot more context.

Re: Invoice with supporting pages?

Posted: Tue Jan 01, 2019 4:57 pm
by TestBoy
Ok, attached is an ENTIRE WORKSPACE that illustrates what I am trying to do.

Note that the subreport variables are indeed empty when you run it. I need those variables because in my real subreport they are passed to SQL.
These are very simplistic examples.
I need to know where and how those get passed in.... and remember, I don't know this like you chaps do so you have to tell me like, exactly where and how I get there.

Re: Invoice with supporting pages?

Posted: Thu Jan 03, 2019 2:08 pm
by Lech Kulikowski
Hello,

To use Parameters in SubReports, you should use the expression:
{this["ParameterName"]}

Thank you.

Re: Invoice with supporting pages?

Posted: Thu Jan 03, 2019 6:16 pm
by TestBoy
But my subreport needs the variables to pass into it's SQL query?
Am I not able to do that?

My example didn't have the variables or the SQL query to keep it simple.

Re: Invoice with supporting pages?

Posted: Thu Jan 03, 2019 9:09 pm
by Lech Kulikowski
Hello,

You can use SubReport parameter in the query:
select * from Categories where CategoryID = {this["SubParam1"]}

Thank you.

Re: Invoice with supporting pages?

Posted: Fri Jan 04, 2019 1:19 pm
by TestBoy
Ok, that worked.
Getting closer!

Here is my next issue. The subreport does run by itself as a regular report in other cases so I still need the variables.
The variables are assigned in the application.
I would like to keep using the variables because in the application I read the Name, Category,Alias, and Description values.
(these are GREAT! btw. Offtopic question: Can we extend these?)
I can work around this by using an IF in my where clause... like .... where GUID=IF( '{this["GUIDParam"]}' = '', @GUIDVar, '{this["GUIDParam"]}' )
Is there a better solution?

Otherwise, I think I am there.

Re: Invoice with supporting pages?

Posted: Mon Jan 07, 2019 11:55 am
by Lech Kulikowski
Hello,

Yes, you can add variable in SubReport and use the following query:
select * from Categories
where CategoryID = {(this["SubParam1"] == null ? Variable1 : this["SubParam1"])}

Thank you.