Microsoft Access Report - How to cycle through all pages of a report in print view? - vba

I have a report that lists business names and the details of that business.
Each business is typically on one page of the report in print preview.
I've managed to create some code that grabs all of the business names and the current page number that they are on and then adds them to a table(BusinessPage). I have placed this code in the 'On Print' section of the report.
Once I cycle through the report, all of the business names and their pages are added to the table (BusinessPage).
The index page then displays the corresponding page numbers for those particular businesses.
Now this works reasonably well, the only problem is: I have to cycle through each page of the report before the index page displays anything (This is because the table is only populated when the page 'On Print' code is activated. Page has to be viewed first before any information is added to the table).
My question is, is there a piece of VBA code that I can use to cycle through all of the pages of a report and then back again? If I can achieve this, it means it will return you to the start of the report and display all of the pages on the index page correctly because the report has already been cycled through.

The solution was to move the code from On Print to On Format.
On Print is only executed when a page is actually printed or previewed.
On Format is executed when the pages are prepared, e.g. by going to the last page in print preview. Or if the page footer contains [Pages]: to calculate the total number of pages, all pages must be prepared, so the code is executed too.

Related

Get page numbers containing a specific object to show at run time

I created a box object(Red box). When I run the application and when report is show, it tends to other pages. How can I get the number that determines which page it's on?

Show all SSRS data on opening report then hide data to single page

I have a tabular report that has Show/Hide grouping on the rows. The end user wants all data displayed when first running the report, which is no problem. It covers roughly 3 or 4 pages. Can I make so that if I hide all the data, it then refreshes to show the "rolled" up table on a single page rather than split across multiple pages?
Go to properties window of the cells you are toggling display.
In the InitialToggleState property select False, it will show all data when you running the report initially.
Let me know if this can help you.
I decided to go with the report all rolled up when first run. Expanding from that state seems to keep the report on a single page plus I can roll it back up to a single page (although probably simpler to just re-run it).

Label printer starts printing blank pages in large jobs

I'm running into an extremely strange issue that a user of mine is reporting:
A Crystal Reports report is printing blank pages past a certain point. My troubleshooting has sort of narrowed down the culprit, but at the same time, has displayed some inconsistent results.
Here's the lowdown:
The application is a VB.NET application, using .NET 4.
There are multiple Crystal Report reports embedded in the solution, and a single form is used to display and print any report.
Which report to display is handled through the code backend, and assigned to the form's CrystalReportViewer object before showing the form.
For the problem report, the datasource comes from a SQL query run in the code, and then assigned as the report's datasource, and then the report is assigned as the reportsource for the CRV object in the form.
The label printer is attached via USB to the computer in question, with the installer used to provide the drivers.
If it matters, it's a Citizen CLP-7201e label printer.
The code that assigns the datasource to the report is as follow:
myCommand = New SqlClient.SqlCommand(strSQL, conPlanning)
myCommand.ExecuteNonQuery()
Da = New SqlClient.SqlDataAdapter(myCommand)
Da.Fill(dsData, "TempPrintLabels")
rptPrintLabels.SetDataSource(dsData.Tables(0))
rptPrintLabels.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Portrait
frmReports.rptViewer.ReportSource = rptPrintLabels
frmReports.Show()
strSQL is a basic SQL statement, based on which report is selected from this particular form. The report's SQL query is, SELECT * FROM TempPrintLabels.
There's the basic info. The report generates fine, and for reports with ~100 labels, it prints fine. The strangeness happens when the report exceeds that limit; it's somewhere in the 95-120 label range. It doesn't seem to be consistent. The report will print, up until it hits that certain point. At that time, it will print nothing but blanks for the rest of the report. There will be as many blanks as there are supposed to be remaining pages. If you start the job again at the point where the blanks started, though, it prints fine.
When I look at this report in the CrystalReportViewer, it looks fine; all the labels render properly. When I print it to a PDF or text file printer, all the pages are there. So the report and print generation seems to be working to me.
I thought it was the printer. To test that, I printed a 185 page job to PDF, and then printed that to the printer. That printed absolutely fine.
I'm at a loss to explain this, or even diagnose this further. There is no code in the form for printing; it uses the CrystalReportViewer object to handle everything. If it was this CRV object, the printing to PDF should've given me blank pages. It didn't. If it was the printer, it should have started printing blanks from the PDF right around the same point as printing directly from the CRV object did. It didn't.
What else can I look for?
For this question, I have some thoughts which causes this behavior while printing.
It may the width issue of your all label's length exceeds from the page size. So you can check all the labels and pages are not blank when you shrink the width of labels (even labels not show properly, we can handle separately). If it shows not (as currently you getting), then you just handle labels width by "Can grow" option to true for all labels.
If everything fine, then I think you can check your printer's page setting / margin.
If above is not work, then either create new report or existing report with just adding static labels and values and then first preview and then call from code. Something you find with this.
As per my experience(I may be wrong in this case), whenever blank page comes in crystal report when your columns will increase, the report's width create an issue. So either set report width to decrease or set printer page bigger. So it print, other wise it not throw error, but give blank pages.

How do i find the location of a page break in SSRS in RDL source?

I have a report with a page break in it that I want to remove, but I don't know where the break is being added. It could be on a table, a group, or I don't know where else.
I checked the tablix properties and group properties for each portion of the report to see if "add a page break before" or "add a page break after" were checked, but didn't find anything.
Is there something i can search for in the RDL source code that will help?
I usually find this occurs when the item (tablix, chart etc) will fit entirely on a new page but not entirely on the page where the control starts. For example if you have a header on page 1 but not on page 2 or you have a chart before your tablix and the tablix will not fit entirely on Page 1 but will fit entirely on Page 2 it chooses to put the tablix on Page 2 instead of half on Page 1 and half on Page 2.
If this is your issue try placing all elements inside another element (such as a rectangle, list or another tablix).
We would need more information to give a more specific answer. Can you post screens of the pages either side of the elusive page break?
I was exporting to report type Web Archive (MHTML) and the page break was coming from the interactive height of the report. Once I set it to zero I no longer got the page breaks.

iterating through a list of records in a second (html) page, where the first page orders the results

I'm building this site using jsp / servlets on the backend.
The first page (or "search" page) allows one to search for records from a table, and also allows the user to sort the records. The sorting mechanism is quite complicated, and is not just a matter of appending an "order by" to an sql query.
The first page then also fills in the results after the user hit's "search". Basically, it's just a list of the items in "short" format, where each item also contains a link to display the item in the second page. The sorting mechanism is run in the first page, while the list is being created. The mechanism uses java code to sort, not sql (for reasons I won't get into, but they are definitely needed).
When the second page (or "details" page) loads, it grabs the id of the record from the url, then displays the details for that record.
Problem is that we now want to put "back" / "next" type iteration features in the details page, so that the users don't have to return to the search or list page to then navigate to the next item in the list.
I'm looking for some ideas on how to implement this as something tells me I'm missing the obvious here. Basically, the problem is that the details page has no concept of the sorting used in the search page, and so has no idea of what the next or previous record in the list should be. There are a few ideas running around but they all suffer from one problem or the next.