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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting a secondary page?

Status
Not open for further replies.

zee3are0

Programmer
Apr 21, 2011
5
US
I have a government standard two page report. On the front page, a fairly elaborate header with some dynamic data, pulled from multiple resources. A single line (form number) for a footer.

I have a temporary table that just contains the basic information I need in order to find out how many records go into the main part of the report's front page, and the data I need in order to populate everything else (a series of DAO and Domain Lookups based on what's in the form used to open the report and the names in the temporary table). The temp table isn't an issue at all; the report's on-close event empties the entire table, and the form that opens it also populates it correctly. Never had any bugs with that.

I then use the "Me.Line" function to draw all the borders for the entire page, regardless of how many records contain data. This way it looks like the actual governmental form.

Basically, the first page looks and performs perfectly. The problem is, there is a back page too. And it's totally different.

If this report was always going to be only two pages, I'd be fine; inserting a Page Break control in the Report Footer allows me to do everything I want then. But if there are more than 21 names in the table, it needs a second "front page" and both front pages need a specific back page. On that page, it has dynamic data that is only as dynamic as the header on the front page. In the case of more than 21 records, I'd have "front page, front page, back page." The report could theoretically contain as many as 100 records, or 6 pages worth of "front pages."

I've learned how to turn the header (and footer) off, as well as to cancel the drawing of the lines that format the sheet on each even numbered page - programmatically, that was easy, but there is nowhere I can insert the controls or other data for a second page between each "front" page. I've tried adjusting positions of controls in the formatting events, but that's only going to change the formatting for the header and footer appropriately either; the size taken up by the Detail section repeated 21 times on the front page is the bulk for screen real estate.

Inserting a "Page Break" control into the page footer appears to have absolutely no effect, and even if it didn't, creating a page footer large enough for the second page doesn't allow me to print it either - I get the error that the size of the page is too big to display.

Is the solution going to be creating two subreports, each side by side, where the main report's width is the equivalent of two printable pages, and then going back into code and redrawing everything with an added qualifier (instead of "me.line" make the line me.subreport.line" and using the code to make sure it's only doing that on even numbered pages) still going to work? Or will the dynamically changing size of the detail section in that sub-report screw up the sizing of the second? Further, will the second page automatically print behind each first page? I don't want to try that (because it's a TON of work) if someone knows if it's going to fail, or that there is another, more elegant solution...

Other solutions "outside the box" would be nice. I've thought about exporting each page of the report to a PDF, but we don't have a distiller on each computer (this application has to be able to run on several hundred computers with their given licenses), so that isn't a real option either. On the other hand, if there is some sort of way to "export" the formatted page for printing to a PDF, and do a for loop that will append the second back page each time, I could automate that and then open the report in Acrobat. I'd need some example code if that's possible. But again, without a commercial distiller, I don't see that as a viable option.

Any suggestions?
 
My first thought is to use the group header as your 'front page'... Does that help?

If not I'll have to read closer ;)
 
I tried that... Nope - there is nothing specific about the grouping of the items (there's only a single field in the temp table, and even if there wasn't, it wouldn't matter - all that determines moving to the second page is the number of records exceeding 21).

I'm actually experimenting now with making what used to be the Detail section full height now, and filling it with a sub-report, sizing it appropriately so that the whole thing fits vertically perfectly to look right, then "forcing" the second page on an extra-wide report format to come out right. That way I don't need to modify the drawing code at all - the detail heights are still valid (I know that the section(0).height used to be 360, so to force it to draw at that exact height). Just have to set the detail section to exactly 7560 twips in height, and make the second page look "right."

If this works out, I'll explain what I did so if anyone else ever has this problem they won't tear their hair out like I've been doing.
 
zee3are0 said:
there is nothing specific about the grouping of the items (there's only a single field in the temp table, and even if there wasn't, it wouldn't matter - all that determines moving to the second page is the number of records exceeding 21).

The only thing clear to me is that I don't understand the dataset.

If 21 records is your problem and you have a temporary table why not add an autonumber column and group by (ID \ 21)? --- note the backslash for integer division.
 
Yeah, actually turned out that just expanding the detail of the form to be the size of the original Detail section (section(0)) * 21, making the original report no longer bound to any data, and making a sub-report of the exact same size as the original report's Detail section, but bound to the table worked out perfectly. I then increased the width of the entire report's area to approximately two pages wide, and adjusted my margins appropriately, filling the "second page" out on the right in with all my "back page" data.

I even left the "me.line" drawing code in the parent report. When the sub-report's number of records requires a second page, then a third and fourth now print, with the right data on all of them. The data in the header and on the back page is not record dependent and only needs data from the form that invoked the report, so some simple Dlookups fixed that.

If anyone else ever has this problem, hopefully a fix like this is viable for them.

As to answering your question, the dataset is simply a list of names. If there's more than 21 names, a second sheet is required. This is for filing static-line and free-fall jumps; our bases' aviation resources management office requires a hard-copy of a form that has 21 blanks on it, and if we throw, say, 64 guys out the right paratroop door, I have to print 4 different sheets out, and each sheet needs a back page. This used to be all hand-done, but I've automated the vast majority of my unit's functions with lots of code, and this was an area where we were deficient. Automating the tracking of our training has helped us a lot, but then copy+pasting all that data into a form filler software was a pain in the rear for a day that might have 50 guys jumping three different times. That's 150+ copy/pastes, plus putting X's into a lot of little boxes. And on top of that, we sometimes need to pull data on an individual's jump history... I wrote the report to print that out (luckily a single-side sheet of paper) yesterday, so now we have a huge time-saver for my users.

For this recordset, there's nothing in the table other than the names of the guys assigned to that specific jump, therefore no reason to group them other than as a running sum every time that sum reaches 21. Even then, I think this way is easier, albeit less elegant. My solution looks (and feels) more like a hack than a perfect solution (which would have a lot more code and a lot less drawing), but as it is, it gets the job done.

Thanks though!
 
Actually, there was an issue, but it was easily fixed... I still used the "double page wide" setup, but I had to move all the data out of the detail section into another subreport, which had a single cell of data on it. The same code which created the temporary list of names for the data source for the first page would, every time it reached the "22nd" record, (so, on 22, 43, 64, 85, etc.) also create a single record in the second table. Then a hidden control the second page's subform was bound to that field.

Thus, if there's 22-42 records in the table bound to the first subform, there's two records in the table bound to the second subform, but the first subform can fit 21 records per page, while the second subform can only fit 1 record per page.

Works flawlessly. But wow, what a pain.

I had looked all over google and countless resources, and I never did find a solution, so anyone curious, this is a way that works...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top