Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to hack details band's -> "start detail band on new page when less than" at run tim 1

Status
Not open for further replies.

KALP1

Programmer
Aug 26, 2016
102
IN
I have a report where I have to set variable value of "detail band on new page when less than" depending on the content of the page . Is there any way to do that.

Will making Report listener's object help and in which method it would be written.
 
You don't mention which version of Visual Foxpro you are using so we cannot be certain that what we suggest will be supported by your version.

Regardless, why can't you use the standard feature?
Open Report Form
From top VFP menu - Report - Edit Bands...
Select Detail 1 and click OK
On the Band tab page you can enter your selections to get what it sounds like you need.​

Good Luck,
JRB-Bldr


 
JRB-Bldr--Since the OP mentioned report listeners, I think we can safely assume VFP 9. The OP can't do this at design-time because she needs to set it based on the content.

I haven't done anything like this, but I would think a report listener would be the way to go.

Tamar
 
JRB-Bldr - I am using VFP 9.0 and I have to keep the height variable, so can't do it at design time as Tamar mentioned.

My 1 thought is that to copy the FRX and then at run time change the value of column "Width" for objtype = 9 and objcode = 4 for that detail band (as Column 'width' in frx stores space below which detail band would be printed on the next page).

But don't know how much feasible this solution is and how will it work.



 
My requirement is I have to print these labels of variable height in a detail band .
If there is not enough space to print 1 complete label, then it should start on the new page.

Mr. Robert Winson
32,Park Street,lan 2,
Jacaranda Marg M Block DLF City,
Pasadena,California

Mr. Jacob Willson
Sector2,NH2,
Illinos

Mr. Edwin Page
450 Serra Mall, Stanford, CA 94305,
United States

Ms. Carl Sherry
1700 American Blvd E,
Bloomington, MN 55876,
Los Angeles,
United States

***********************************
Right Now I have problem that below lines print on 1 page ->
Page 1 :
Mr. Robert Winson
32,Park Street,lan 2,
Jacaranda Marg M Block DLF City,
Pasadena,California

Mr. Jacob Willson
Sector2,NH2,
Illinos

Mr. Edwin Page
450 Serra Mall, Stanford, CA 94305,
United States

Ms. Carl Sherry
1700 American Blvd E,
.........

** These below lines Print on Next Page ->
Page 2:
Bloomington, MN 55876,
Los Angeles,
United States

* I want to print this complete label on the next page ->
Page 2:
Ms. Carl Sherry
1700 American Blvd E,
Bloomington, MN 55876,
Los Angeles,
United States


 
Hi KALP1,

to solve Your problem, You can't control the detail band height directly, but You can control the detail band height indirectly !

Just take a look at the following screen shot:

report_grouping_hkhy8d.jpg


- Note: I have a german Visual Foxpro

1) Set up a data group (german Datengruppierung): kundenCursor.nr equal to customer.no (must be an unique value)

2) Set the setting Gruppe auf neuer Seite beginnen, wenn weniger als equal to Start group on new page, if less than (???) to 3,0000. Try for this setting the smallest value, that will work for You !

Regards, Stefan
 
Well, that setting is what caused this thread, isn't it? You can only set that to a constant value. But the screenshot also shows another option: Let every group begin on a new page. Why not take that? If it's the goal to never print an incomplete group, printing one per page would ensure that. Otherwise a constant value should at least prevent to only print header and you shouldn't need a variable value for that to help you not to have improper groups where only the header is at the bottom of a page and all data goes to the next, for example. The option to print the head on each page also helps about groups, which are longer than one page.

Essentially you should set the value for tha last option to something about the size of the group header to prevent an orphaned header, that even repeats due to the option to print group headers on every page.

Besides all that, there is a hotfix in regard of that printing group header option, so do you have the latest VFP runtimes in use?
See
Bye, Olaf.
 
Hi Olaf,

for me the question is: has KALP1 already inserted a data group / data grouping ???

I'm not sure - but if he doesn't, he can try my suggestion.

And if he already has, he should try Your additional suggestions. :)

PS: to set the "start detail band on new page when less than" at run time, makes for me no sence. [neutral]

Regards, Stefan
 
Stefan said:
to set the "start detail band on new page when less than" at run time, makes for me no sence

I assume KALP1 wants control about where a group starts. If you can compute how long a group is you may be able to decide on a page by page basis whether or not to do a page break. To me this also makes no real sense, because in the end you have the simple option to start each group at a new page. Maybe there are very short and very long groups and the goal is to only have whole groups but also not waste space for the very short groups of which several fit on one page.

Bye, Olaf.
 
Hi Stefan,
Data Grouping is not possible in my case,as I have 9 details band and in 7th detail band
I want to print whole information of X1(refer link) if overflows occurs.

Will data grouping be possible for 7th detail band

Another Thing For each cust id, there would be 3-8 lines max,so grouping data with min. height of 3
would leave much space after each custid leading to waste space.
As My report is for printing thousands of pages, It would not be a feasible solution.

As Olaf suggested, starting group on new page will not work as I have no problem whether group starts on new page or not,
Just problem is at page break when 1/2 info. is printed on 1 page and 1/2 on another.

I have 3-8 lines for each customer. And in each page ,there are around 8-10 customer's details printed.
My Requirement is to print whole info. for each cust id even at page breaks


Regards Kalp1
 
Hi KALP1,

thank You for Your feedback and Your screen shot !

Your report is a bit more complex and complicated, as You described or as I had assumend [smile]

Regards, Stefan
 
Is There any way to get the top of currently executed field
Or Space Left From The Current Line To The Bottom Of The Page.

I have precalculate no. of lines required to print per custid.
if I get space left on the page,then rest space/space for each line would give how many lines could be printed in the rest of the page.In that case I could insert that many blank lines to cover rest page if no. of lines required for custid is more than available space.
 
You can have multiple detail bands within a group and besides that you seem to make a band per line of printing, why? You can put report controls in several lines in the same band.
Anyway, you have a natural grouping by custid, so make use of that. If you want to save paper you should really consider printing 1/2 and 1/2 info, there is just one unfortunate way of interruption of a group, if only the header makes it on the end of one page, and to prevent that the minium height is sufficient.

Bye, Olaf.
 
Olaf - You are not getting my requirement and I m not printing 1 line/ per band and already have grouping(sales person wise and not customer wise).
I have to print mailing labels along with summary and other info.
I just want mailing label of 1 customer to be printed on 1 page.

I have my report layout as
Sales Person(Data Grouping)
- summary of Sales person under him
- summary of customers made by him
- details of customer(mailing labels) - This has to be printed in single page for any custid if page break occurs
- ......
- ......
and so on
 
Thanks To Olaf And Stefen for ur replies.
I Got Soln After Sweating Blood For 2 Days.
Approach I followed is totally new to me.

In report I have placed a shape object in the report and created a reportlistener's class.Reportlistener have AdjustObjectSize Events which is called to adjust size of the shape object at runtime.
In this event ,Parameter Object oObjProperties have 1 property- "maxheightavailable" which was useful to find out available room on this page for this element, so at each element I checked whether space for mailing label of 1 custid was less than available space or not . If not then make height of the shape object = maxheightavailable which filled rest of the page space and forced underlying labels(make object position to float) to print on the next page.






 
Some more ideas:

Assuming each line height is the same and you can print 50 lines per page.

Add a field call it may be LINENO N 4
and another one call it may be NEWPAGE L
Have the table ready to print with no active index.

Update LINENO from 1 to 8, for each label, assuming you have maximum 8 line per label.

Run a preporcess as follows
Code:
do while not eof()
   skip 50  && Page length
   if not eof()
      skip  && check the status of the next record
      BlanksToInsert = 0
      do while LINENO <> 1
         skip -1
         BlanksToInsert = BlanksToInsert + 1
      enddo
      replace NEWPAGE = .t. 
      * At this point you are pointing to the first line of the label such that you can eject page
      * I think there is an option in report writer to eject page when condition is true.
      * Alternately you can add blank records(BlanksToInsert) just before this record.    
   endif
enddo
go top
* Now send to printer like report form ....

 
Hi NasibKalsi,
Your approach is correct when u have fixed no. of lines per page.In my case problem was that I had 9 detail bands of variable lenght and depending on condition detail band will be printed. In this scenario, I don't know from where my detail band say 7th detail band starts and also how many no. of lines would fit for that particular band in a page.

Regards Kalp1
 
Yes, it's possible.
In the next link you'll find a solution.

Excerpt
"I found a solution without subclassing the reportlistener, but it's slow and not intuitive.
Basically, the report is executed more times. Each time one more record is moved to the next page."

Keep lines together in a VFP report

I recommend to read the entire thread, especially
The next reply
and
Some explanations
More explanations

Related to this, please read
Unexpected behavior of a two (or more) detail band report.

Respectfully,
Vilhelm-Ion Praisach
Resita, Romania

 
Well, I can only summarize this as a problem not presented in enough detail to know what you need. Yes, I (we) could have simply swallowed your idea of letting N bands float to next page, if they don't fit. Reporting is not my favorite part of VFP at all, that maybe contributing to my ignorance of that wish, I also still think holding together something could be done without such trickery, if things that should not break (break up on two pages) are hold together in some way, same band for example. I don't think you need as much bands as you use, if you'd simply prepare your data better for a straight forward report, by joining.

Anyway, nice you found a solution, I would have proposed a word automation as a solution to have better control about pages. The most similar thing I once proposed was using an invisible line to let elements float and let it shift them down in thread184-1762345.

Better luck with a faster solution next time. Such complex problems are often enough better solved with hands on, it'll be hard to find developer groups with a regular meeting to discuss and tackle such things. If you're in europe you might ask for a regional group meeting to attend.

Bye, Olaf.
 
Vilhelm - I read your post,partially got what you are explained. Learned a new approach for using Report Listeners without subclassing.
This would not be a feasible solution for me as, as many times page break occurs, report is re- run. In my report I have thousands of pages to print and in 4-5 pages approx. 1 page break occurs ,so it would a long time for printing, but approach was really appreciable.

Olaf - I have already used the technique you mentioned in some another report.In this report it was not possible as the problem was how to know space available from current element till page footer.If you have some other sugesstions, It would be highly welcomed.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top