• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4843
  • Last Modified:

Programmatically add blank records in Detail Section

I have a report where the layout is setup so that the data is printed in a tabular format, where the data is obtained from a SQL Server stored procedure.  Thus, if I have 13 records, then I will get 13 rows of data produced in the Detail section.  In addition, I have set the CAN GROW property of one of my textbox fields in the Detail section to true.  

The report is capable of holding 25 records, if the previously mentioned textbox does NOT grow.  If it grows, then there's no telling how many records the page will actually contain.  Here's my problem:  Regardless of now many records are actually able to fit the report, I would like to fill the detail section with BLANK rows if the data obtained did not fill the page.

For example, say none of the records will cause the textbox to grow. Then this means I can have a total of 25 rows on each page.  However, say, instead of 25 records, I get 15.  Then, I would like to programmatically add the remaining 10 records, as blanks, into the detail section so that the report looks filled.  

When the textbox grows, this is even hairier, because now I don't know how many blank rows I'll need to add.

Any ideas.

By the way, I'm using the Crystal Reports Bundled edition, wich came with VisStudio .NET 2002.
0
rarich02
Asked:
rarich02
  • 5
  • 4
1 Solution
 
frodomanCommented:
What is your intention for adding blank rows?  

If you have a report footer that you want to display at the bottom of the page, you can simply check the "print at bottom" box in the section expert.

0
 
rarich02Author Commented:
1) The blank rows allow a person to Hand write any additional records they may need after the report has been printed out.  
2) It makes the report look complete, with the blank rows filling any empty space that has not been populated with records.
0
 
frodomanCommented:
I guess where I'm confused is normally the bottom of the page will be blank whether there are "blank" records or not, so I was guessing that you must have a footer or something that you want at the bottom of the physical sheet of paper to get the "complete" feeling.

In any event, Crystal isn't going to print blank records so the closest you'll be able to get will be to create a formula for the last record that will insert a number of carraige returns (or text or whatever you want).  If you want to pursue this I can show you a formula to do it.

The problem is that the "can grow" is going to screw you up no matter what.  I can show you a formula that will insert five carraige returns after record number 20 however there is no way to calculate accurately if you really only need 3 carraige returns because two of the prior records "grew."  
0
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 
rarich02Author Commented:
Currently, I figure there are two ways this can be done:

1) Disallow the CAN grow property of the text box. This way, I know that I will always have 25 records.  Then, on the SQL Server side, let my Stored procedure calculate how many extra "Blank" records I need and add them to the recordset I'm returning.  Then, using the Sorting feature, I'll make sure that the Blank rows will always be the last rows to be printed, in effect filling my last sheet with "Blank" rows.

2) If I could programmatically determine when I've hit my last record, then I'd like to somehow tell the detail section to continue adding new records to that page.  In order to stop this, I would somehow check to see if I've used up the maximum amount of space that the Detail section can use for that page.  If this can be done, then I'd prefer this solution since then, the CAN GROW property would not matter anymore.

Any ideas
0
 
frodomanCommented:
#1 is certainly a viable alternative and is IMHO your best choice.

#2 you can determine when you've hit the last record easily.  You cannot add new records within Crystal (hence my suggestion to add carraige returns instead).  With a c/r the approach would be a formula like this in the detail section:

numberVar x;
if OnLastRecord then
  (
  numberVar RowsToAdd := 25-RecordNumber;
  for x := 1 to RowsToAdd do
  (
    chr(10) + chr(13);
  );
  );

This adds a carraige return / line feed for every record < 25.  

You aren't going to be able to check the space needed with the can grow though or how much space is needed.  Crystal exposes recordcounts and end of file indicators but it does not expose end of page indicators.  You simply aren't going to be able to do it exactly the way you want.

Hope that's helpful.
0
 
rarich02Author Commented:
Thanks for the info.  I'd be more than happy to give you the points if you can help me find the documentation supporting your statement.

Thanks
0
 
rarich02Author Commented:
"You aren't going to be able to check the space needed with the can grow though or how much space is needed.  Crystal exposes recordcounts and end of file indicators but it does not expose end of page indicators.  You simply aren't going to be able to do it exactly the way you want"

Thanks for the info.  I'd be more than happy to give you the points if you can help me find the documentation supporting your statement.

Thanks
0
 
frodomanCommented:
I don't know of any official documentation saying what Crystal can't do - most company tell you what their software *can* do, not what it can't do ;-)   You can search this forum though if you'd like because this topic has come up before and there some hit or miss workarounds but nothing that provides a real solution.

I'm the #3 ranked expert on this site and to the best of my knowledge it can't be done.  Below link is where the #1 ranked expert on this site says the same thing - he does suggest a workaround by counting the characters to estimate the number of rows although in my own experience this doesn't work well unless everyone uses the same printer because the margins on different print drivers will throw it off.  http://www.experts-exchange.com/Databases/Crystal_Reports/Q_20891815.html

Cheers,

frodoman
0
 
rarich02Author Commented:
frodoman,

I appreciate your effort.  Looks like I'll be going with Solution #1.  Thanks.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now