Solved

Programmatically add blank records in Detail Section

Posted on 2004-03-25
9
4,141 Views
Last Modified: 2010-12-31
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
Comment
Question by:rarich02
  • 5
  • 4
9 Comments
 
LVL 42

Expert Comment

by:frodoman
ID: 10679630
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
 

Author Comment

by:rarich02
ID: 10680183
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
 
LVL 42

Expert Comment

by:frodoman
ID: 10680445
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:rarich02
ID: 10681885
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
 
LVL 42

Accepted Solution

by:
frodoman earned 500 total points
ID: 10682182
#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
 

Author Comment

by:rarich02
ID: 10687419
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
 

Author Comment

by:rarich02
ID: 10687423
"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
 
LVL 42

Expert Comment

by:frodoman
ID: 10687583
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
 

Author Comment

by:rarich02
ID: 10687973
frodoman,

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

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

770 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