How can i set a fixed height detail section in crystal reports regardless of record count.

I set the height of detail section to 10 records. If i put 8 records, the space for other 2 records should be white space. That is, total height remain the same.

Please help me,

Thanks,

Just went through this exact situation a few weeks ago myself. Suprisingly there is not an easy solution for this although I did find a work around.

There is no way to set the total height of the details section iteself, only the height of the individual item records. So the first thing you want to do is calculate the indivual record height and then the total for all 10 records. So say the height is 136 for each individual details record, total for 10 shown records should equal 1,360.

Ok under the details section add a Footer section to the report. If you are actually using a footer section, you can add an additional footer. You just want to make sure this blank footer is directly underneath the details section. Set this new blank footer to your total size: 1,360

Now Im not sure how your report is set us to draw the data. Are you allowing the report itself to query directly from the database or passing it a filled dataset? I'm doing the latter. Either way before you display the report you need to know how many records will be displayed so you can adjust the height programmiticaly.

Now the footer does allow us to adjust its height from VB. So I'm creating a blank section that would appear to be the size of 10 records if no records at all were returned. Now what we want to do is shrink this footer for each record that is going to be displayed. So if 8 records are returned, the size should be reduced by (8 * 136) 1088. So the total Footer blank space that should still be visible is (2*136) 272.

In my example, I named the Footer "BlankRecords" but you can use the default of change it appropiately. Basically all Im doing is adjusting the size of the footer before sending directly to the printer.

Dim rpt As New rptMyReport

rpt.BlankRecords.Height -= (ds.tblItems.Count * 136)
rpt.SetDataSource(ds)
rpt.PrintToPrinter(1, False, 0, 0)

'rpt.Section4.Height -= (ds.tblItems.Count * 136) 'Another way of call the section

Edited 7 Years Ago by TomW: n/a

Thank you for immediate reply..

This is a cheque printing application. My report structure is as follows

==========================================
Comapny Details
---------------------------------------------------------------------------

Invoice

---------------------------------------------------------------------------
Cheque
==========================================

I need to make height of invoice section remain fixed. Report data are driven from ms access database.
Let me try your idea.

Thanks,

Just went through this exact situation a few weeks ago myself. Suprisingly there is not an easy solution for this although I did find a work around.

There is no way to set the total height of the details section iteself, only the height of the individual item records. So the first thing you want to do is calculate the indivual record height and then the total for all 10 records. So say the height is 136 for each individual details record, total for 10 shown records should equal 1,360.

Ok under the details section add a Footer section to the report. If you are actually using a footer section, you can add an additional footer. You just want to make sure this blank footer is directly underneath the details section. Set this new blank footer to your total size: 1,360

Now Im not sure how your report is set us to draw the data. Are you allowing the report itself to query directly from the database or passing it a filled dataset? I'm doing the latter. Either way before you display the report you need to know how many records will be displayed so you can adjust the height programmiticaly.

Now the footer does allow us to adjust its height from VB. So I'm creating a blank section that would appear to be the size of 10 records if no records at all were returned. Now what we want to do is shrink this footer for each record that is going to be displayed. So if 8 records are returned, the size should be reduced by (8 * 136) 1088. So the total Footer blank space that should still be visible is (2*136) 272.

In my example, I named the Footer "BlankRecords" but you can use the default of change it appropiately. Basically all Im doing is adjusting the size of the footer before sending directly to the printer.

Dim rpt As New rptMyReport

rpt.BlankRecords.Height -= (ds.tblItems.Count * 136)
rpt.SetDataSource(ds)
rpt.PrintToPrinter(1, False, 0, 0)

'rpt.Section4.Height -= (ds.tblItems.Count * 136) 'Another way of call the section

If you need any help just let me know. My example sends the report directly to the printer without displaying it on the screen first, but the same applies, set the footer size before displaying the reportviewer.

In case I made the above sound more complicated then it is, basically all Im doing is using the blank footer space to emulate the white space of any missing records so that in appearance the details section appears to be a fixed size.

I cant believe that there wasnt an easier solution to this but as said, I had the same problem and spent time researching it and this is the best that I could come up with for resolving the problem.

Glad to help. Sorry there isnt an easier way or atleast one that I can find, I definitely need to accomplish the same thing for some forms. There is also one other way I know of that consists of using subreports. I didnt think to mention it because I have discounted them myself previously, too slow to load and print...

I finished developed that application. I deployed on the client machine. But I cannot connect to the database. Where i will store the database. I copied in the same directory as .exe .

I get "could not find file" error.

This is my first windows application.

Thanks

I would need more details in order to help. What database are you using, what is you connection string etc.... Mark this thread as solved and start a new one about the connection strings and I will see if I can help.

The best solution is to have the report itself monitor the details area. Here is a report solution (not a vb) as found in another blog post.

If you format your page header and footer to take up the appropriate amount of space at the top and bottom of the page then the detail section will fill the middle with as many records as will fit in.

1) If you are using a group with a group footer visible, then check "Print at Bottom of Page" in the section expert and format its size as required.

2) Alternately, one can add the following formatting formula to "New Page After" for the detail section:

RecordNumber MOD 10 = 0  ' Allow 10 Records to fill the details area

Edited 5 Years Ago by wsfaso: n/a

This question has already been answered. Start a new discussion instead.