Print preview last page..

R

Richard

I would like to preview the last page im my report:

Private Sub Command13_Click()
On Error GoTo Err_Command13_Click

Dim stDocName As String

stDocName = "rptScanlog"
DoCmd.OpenReport stDocName, acPreview

Exit_Command13_Click:
Exit Sub

Err_Command13_Click:
MsgBox Err.Description
Resume Exit_Command13_Click

End Sub

Thanks and happy new year to all.
 
W

Wayne-I-M

Private Sub ButtonName_Click()
Dim I As Integer
DoCmd.OpenReport "ReportName", acViewPreview
I = Reports!ReportName.Pages
SendKeys "{F5}{Delete}"
SendKeys I & "{ENTER}"
End Sub

Change ButtonName and ReportName to what they are in your application


Happy New Year
 
R

Richard

Awesome thank you, could you talk a little about the 2 sendkeys lines and
how I could use that.
 
W

Wayne-I-M

Sendkeys are (very simply) a code that repreents you hitting a key on the
keyboard.

Open the code window and press F1 help and search sendkey and you will get
lots of examples of keys
 
J

John W. Vinson

Sendkeys are (very simply) a code that repreents you hitting a key on the
keyboard.

Open the code window and press F1 help and search sendkey and you will get
lots of examples of keys

It should be noted that Sendkeys is generally recommended only as a last-ditch
choice when there's NO other way to do it; the problem is that you have no
guarantee that the key value being sent will get to the right destination. If
you have multiple windows open, the character may end up in some other
application.
 
W

Wayne-I-M

Thanks for that John

I would think that it should be possible to check for other open "stuff" and
close them on some OnClick or warn to user then, if nothing is open then run
the code. But I can't see the OP's application and we don't have enough
details for this.

Is there another method of previewing on open the last page of a report
without using sendkeys?

PS - happy New Year
 
R

Richard

I would welcome other methods of print preview the last page also. If the
sendkeys are known to have problems.

Thanks Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top