?
Solved

Crystal Report counting record

Posted on 1998-09-25
4
Medium Priority
?
1,671 Views
Last Modified: 2013-12-25
I have a report in crystal report. It is a invoice report. It has a grouping on invoice number and a detail section where the "products" are listed.
Of different reasons I have to use a variabel MaxNuberOfLines and when I reach the correct number of lines I add a page break. When all the records for one Invoice is printed I print the invoice sum and print the giro that are in the page footer.

I been able to to all this (almost) having only one challange left.

Let say it is allowed to print execly 4 records per page. So if it is 6 records I will have 4 on page one and the two other on page two as well as the giro and the invioce sum.
This works OK but if it is 4 records on the invoce I gets the for record on one page and the sum/giro on the other. This is not want I want, I want it all on one page.

Here is the code for the detail_format I have
(Linje is norwegian for lineNr

Linje = Linje + 1 'counting the lines
If (Linje = MaxNuberOfLines ) Then 'reach the maxlines
    Linje = 0 'put the counter back to 0
    Me.Section3.NewPageAfter = True 'add a page break
   
Else
    Me.Section3.NewPageAfter = False 'dont break page

End If

So the thing is that I dont want to put the pagebreak IF it is the last record in section even if MAXLINES has been reached.

anyone?
0
Comment
Question by:perove
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 2

Accepted Solution

by:
BergJC earned 400 total points
ID: 1496396
There may be two ways to solve this one. First, the Crystal Report control has a property called .RecordsSelected. If you use that after you have set your selection formula, it should come back with the number of records you will have. THen you can do this with your code:

Linje = Linje + 1 'counting the lines
    If (Linje = MaxNuberOfLines ) and (Linje < Section3.RecordsSelected)Then 'reach the maxlines
        Linje = 0 'put the counter back to 0
        Me.Section3.NewPageAfter = True 'add a page break
         
    Else
        Me.Section3.NewPageAfter = False 'dont break page

    End If


OR

I'm assuming you have your code in a loop. Somehow you know when to stop the loop. If you know that, use the same condition you use to break the loop for determining when to page break. If the loop is ready to end, then don't page break.
0
 
LVL 2

Expert Comment

by:BergJC
ID: 1496397
If my second solution didn't make any sense, post the rest of you r code for this function and maybe I can figure it out then.
0
 
LVL 2

Expert Comment

by:BergJC
ID: 1496398
One other note, for your .RecordSelected to actually show the correct number, you must do a Me.Section3.RetrieveDataFiles command first, but it must be after your .RecordSelectionFormula property is set (if you have one).
0
 
LVL 9

Author Comment

by:perove
ID: 1496399
YES!!!
Just what I've been looking for!!
thanks
perove
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

765 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