473,320 Members | 1,936 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to browse through report pages automatically?

176 100+
Hello forum!

I've combined table of contents subreport to a report using Microsoft function:
http://support.microsoft.com/kb/210269

The table of contents table combines itself if user goes through all the pages of a report first. Is there a way to make Access to go through all the pages of the report automatically, without showing this operation, in order for the table of contents table to be generated for the user as he or she views the report?

Thanks!
Aug 6 '07 #1
9 7073
FishVal
2,653 Expert 2GB
Hello forum!

I've combined table of contents subreport to a report using Microsoft function:
http://support.microsoft.com/kb/210269

The table of contents table combines itself if user goes through all the pages of a report first. Is there a way to make Access to go through all the pages of the report automatically, without showing this operation, in order for the table of contents table to be generated for the user as he or she views the report?

Thanks!
Hi, Michael.

I suppose it may be a Form with timer, where OnTimer event handler send {PGDN} key to the Report window via SendKeys function.
Aug 6 '07 #2
Michael R
176 100+
Hi, Michael.

I suppose it may be a Form with timer, where OnTimer event handler send {PGDN} key to the Report window via SendKeys function.
Thanks FishVal,

And how does the program will know to close the report, when getting to the last page?

Michael.
Aug 6 '07 #3
FishVal
2,653 Expert 2GB
Thanks FishVal,

And how does the program will know to close the report, when getting to the last page?

Michael.
Report.Page property returns current page number, Report.Pages property returns total pages in a report.
Aug 7 '07 #4
Michael R
176 100+
Report.Page property returns current page number, Report.Pages property returns total pages in a report.
That works.
Thanks a lot.
Aug 7 '07 #5
Michael R
176 100+
That works.
Thanks a lot.
I'll have to get back on this:

I've tried to create a procedure that will browse the form and close it, with no avail:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Report_Open(Cancel As Integer)
  2.     Call InitToc 'procedure that creates table of contents for the report and will be shown
  3.                  'on the first page of the next openning.
  4.     Delay (5)
  5.     MsgBox Me.Pages 'returns 0
  6.     For i% = 1 To 100 ' i cant use Me.Pages or Reports!myReport!Report.Pages because they return 0, instead of 100+  - why is that?
  7.         SendKeys "{PGDN}", True 'an error pop-up box is shown and says 'The action can't be carried out when proceeding other events'
  8.                                 'also, this command is being generated BEFORE and not after the report loads all its data, which is ipropriate
  9.     Next i%
  10.     DoCmd.Close acReport, "rptVisit" 'this command doesn't executes at all
  11. End Sub
Expand|Select|Wrap|Line Numbers
  1. Sub Delay(Delay_Time As Integer)
  2.                      'Delay_Time > Sets duration.
  3.     Start = Timer    ' Set start time.
  4.     Do While Timer < Start + Delay_Time
  5.         DoEvents     ' Yield to other processes.
  6.     Loop
  7. End Sub
Aug 11 '07 #6
Scott Price
1,384 Expert 1GB
From M$ Help file:

Remarks
You can use the Pages properties in an expression, a macro, or Visual Basic.

This property is only available in Print Preview or when printing.

To refer to the Pages property in a macro or Visual Basic, the form or report must include a text box whose ControlSource property is set to an expression that uses Pages. For example, you can use the following expressions as the ControlSource property setting for a text box in a page footer.

This expression Prints
=Page A page number (for example, 1, 2, 3) in the page footer.
="Page " & Page & " of " & Pages "Page n of nn" (for example, Page 1 of 5, Page 2 of 5) in the page footer.
=Pages The total number pages in the form or report (for example, 5).
Also example from same source:
The following example displays a message that tells how many pages the report contains. For this example to work, the report must include a text box for which the ControlSource property is set to the expression =Pages. To test this example, paste the following code into the Page Event for the Alphabetical List of Products form.

Dim intTotalPages As Integer
Dim strMsg As String

intTotalPages = Me.Pages
strMsg = "This report contains " & intTotalPages & " pages."
MsgBox strMsg
Part of the problem is that reports are not automatically paginated like forms are... i.e. the record counter on the bottom of a form shows what record you are currently viewing as well as the total records avail... Reports may show the current page, but will not show total pages in the equivalent navigation buttons on the bottom of the print preview window. This is because the pagination of a report (especially long reports) takes plenty of time, and should only be done as necessary (which M$ says is on print, not preview).

These examples from the help file appear to work around this problem, but only by referring to a PageCount control placed somewhere on the report.

Hope this helps!

Regards,
Scott
Aug 11 '07 #7
FishVal
2,653 Expert 2GB
I'll have to get back on this:

I've tried to create a procedure that will browse the form and close it, with no avail:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Report_Open(Cancel As Integer)
  2.     Call InitToc 'procedure that creates table of contents for the report and will be shown
  3.                  'on the first page of the next openning.
  4.     Delay (5)
  5.     MsgBox Me.Pages 'returns 0
  6.     For i% = 1 To 100 ' i cant use Me.Pages or Reports!myReport!Report.Pages because they return 0, instead of 100+  - why is that?
  7.         SendKeys "{PGDN}", True 'an error pop-up box is shown and says 'The action can't be carried out when proceeding other events'
  8.                                 'also, this command is being generated BEFORE and not after the report loads all its data, which is ipropriate
  9.     Next i%
  10.     DoCmd.Close acReport, "rptVisit" 'this command doesn't executes at all
  11. End Sub
Expand|Select|Wrap|Line Numbers
  1. Sub Delay(Delay_Time As Integer)
  2.                      'Delay_Time > Sets duration.
  3.     Start = Timer    ' Set start time.
  4.     Do While Timer < Start + Delay_Time
  5.         DoEvents     ' Yield to other processes.
  6.     Loop
  7. End Sub
Hi, Michael.

Here is tested code. Its a complete module of a form which contains one button opening report and starting autobrowsing.
Report.Pages property will return 0 until the whole report will be formatted.
So there are at least two options:
  • to wait until report will be formatted and then start browsing
  • to consider the report to be on the last page then Report.Page does not grow any more (as in the following example)
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Const Interval = 1000 '1000 ms between pages
  3.  
  4. Private Sub Command0_Click()
  5.  
  6.     Dim stDocName As String
  7.  
  8.     stDocName = "rptSampleReport"
  9.     DoCmd.OpenReport "rptSampleReport", acPreview
  10.     Me.TimerInterval = Interval
  11.     Me.OnTimer = "[Event Procedure]"
  12.  
  13. End Sub
  14.  
  15. Private Sub Form_Timer()
  16.  
  17.     Dim lngPage As Long
  18.  
  19.     On Error GoTo CancelTimer
  20.  
  21.     With Reports!rptSampleReport
  22.  
  23.         On Error GoTo ExitSub 'the next row fails if no report is in focus
  24.         If Screen.ActiveReport.Name = "rptSampleReport" Then
  25.             lngPage = .Page
  26.             SendKeys "{PGDN}", True
  27.             If .Page = lngPage Then GoTo CancelTimer
  28.         End If
  29.         On Error GoTo 0
  30.  
  31.     End With
  32.  
  33. ExitSub:
  34.     Me.TimerInterval = Interval
  35.     Exit Sub
  36.  
  37. CancelTimer:
  38.     Me.OnTimer = ""
  39.  
  40. End Sub
  41.  
Aug 11 '07 #8
Michael R
176 100+
Hello FishVal!

Sorry, I haven't been around for a while...

Your code works very well. A neat way to browse the pages.

thanks :]

Michael.
Sep 18 '07 #9
FishVal
2,653 Expert 2GB
Not a problem.
You are welcome.

Best regards,
Valentine
Sep 18 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Chris Lasher | last post by:
Hello, I'm trying to write a tool to scrape through some of the Ribosomal Database Project II's (http://rdp.cme.msu.edu/) pages, specifically, through the Hierarchy Browser....
1
by: jandoca | last post by:
Hi, I am new to crystal reports and I have to build some reports and call them from an ASP page and display them. I am using Crystal Reports Developer 9.0 and the client has Professional 9.0. I...
87
by: expertware | last post by:
Dear friends, My name is Pamela, I know little about CSS, but I would like to ask a question I have an image on a web page within a css layer: <DIV ID=MyLayer STYLE = "position:...
14
by: expertware | last post by:
Ok! to avoid confusion I will start a new argument. Thanks!! FIREFOX 1.0.7 AND IE6 viewed through DATATIME: a summary REPORT ===============================================================...
2
by: John Young | last post by:
I am creating a report / letter that automatically fills in fields from a form when a command button is pressed on the form..... The idea is to create a report /letter containing member address and...
0
by: Jacky11 | last post by:
Hi everyone, I have spent several hours on this topic, and I still don't have the right solution. However, you guys can accomplish in 5 minutes much more then I can accomplish in 5 hours. :-)...
3
by: Paradigm | last post by:
I have a contract document that is about 20 pages long with various data base fields in it. I cannot create an Access report that long so I have had to do it as 5 seperate reports. There are some...
0
by: jason | last post by:
some confusion here. The below code allows me to save a local file to my web server and somehow because the field type is file a local file browse button is rendered. I'm trying to figure out...
1
by: Stinky Pete | last post by:
Evening, I have a form that uses 5 pages (it's an electronic copy of the paper version) we are going to use for manufacturing non conformances and product deviations. In case your wondering,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.