ktalarico Posted March 20, 2007 Share Posted March 20, 2007 What is the correct expression to enter when I want an element to appear only when the number of rows returned from my SQL query is zero? Link to comment Share on other sites More sharing options...
jmurray Posted March 20, 2007 Share Posted March 20, 2007 The Print When expression you would use is something like this: new java.lang.Boolean($V{REPORT_COUNT}.intValue()==0) But be careful: the value of REPORT_COUNT is not available until AFTER the detail section has been filled. That means that you can normally only use that expression in a footer or summary section. There is a way around the problem though. You can use a subquery to return the value BEFORE the detail section is filled because subreports are always filled first. The subreport doesn't need to display anything, it just returns the value of REPORT_COUNT so that you can store it in your own variable within the main report. The subreport's query is the same as the query in the main report. The best place to put it is in a header section, out of the way. Once your variable has the value of REPORT_COUNT from the subreport you can use it in any subsequent band, including the Detail band. The expression now has to refer to your own variable: new java.lang.Boolean($V{yourVariable}.intValue()==0) Link to comment Share on other sites More sharing options...
ktalarico Posted April 4, 2007 Author Share Posted April 4, 2007 Thank you very much. I'm having problems getting my element to print. Can you tell me if I need to modify my destination variable for the REPORT_COUNT in a specific way? (i.e., Calculation Type, Reset Type, Increment Type, etc.) Link to comment Share on other sites More sharing options...
ktalarico Posted April 10, 2007 Author Share Posted April 10, 2007 I'm all set now with the help of some of your other posts. Thanks again. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now