Open report in the last page (1 Viewer)

JPaulo

Developer
Local time
Today, 04:54
Joined
Dec 21, 2009
Messages
185
Hi all;

I want to open a report on the last page, but this code does not work, why?

Access 2003

Private Sub Command10_Click()
Dim I As Integer
On Error Resume Next
DoCmd.OpenReport "Report1", acViewPreview
I = Reports!Report1.Pages
SendKeys "{F5}{Delete}"
SendKeys I & "{ENTER}"
End Sub
 

JPaulo

Developer
Local time
Today, 04:54
Joined
Dec 21, 2009
Messages
185
Resolved, thanks to all the same;

Private Sub Command10_Click()
DoEvents
DoCmd.OpenReport "Report1", acViewPreview
SendKeys "{End}", True
DoEvents
End Sub
 

C.F.

Registered User.
Local time
Today, 00:54
Joined
Jan 7, 2009
Messages
17
JPaulo -- I'm a novice at this, so the simplicity of your code was appealing to me. Form my database, I translated your code into the following as a Event Procedure "On Open" for the report, Rpt EA ITAR Dashboard v4 THIS ONE rpt:
_____________________
Private Sub Report_Open(Cancel As Integer)
DoEvents
DoCmd.OpenReport "Rpt EA ITAR Dashboard v4 THIS ONE rpt", acViewPreview
SendKeys "{End}", True
DoEvents
End Sub
____________________

I still go to the first page when I open the report. Any suggestion?
 

vbaInet

AWF VIP
Local time
Today, 04:54
Joined
Jan 22, 2010
Messages
26,374
What that SendKeys code is doing is calling the END key that is on your keyboard. Hence, that code will not take you to the last page of your report but would rather scroll down to the end of the current report page.

There aren't any methods to manage page navigation in a report unless you were to create an API to "press" the navigation buttons located at the bottom of the report.
 

JPaulo

Developer
Local time
Today, 04:54
Joined
Dec 21, 2009
Messages
185
Hi man;

It works perfectly, but you have to put in VBA event by pressing a button on your form, not the event to open your report.
 

Users who are viewing this thread

Top Bottom