INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Help! I need to output first page only.

Help! I need to output first page only.

(OP)
Help! I need to export a report in PDF format but the trick is I only need to export the first page only. Here is what I have and it works fine with the exception of the output. It outputs all the pages and I only need the first page. Could page parameters be used somewhere in this string?

On Error GoTo Err_Command66_Click
Dim Response1 As Integer
Dim intCopies As Integer
Dim StrReport1 As String
Dim StrReport2 As String
StrReport1 = "Employee_Summary_1"
StrReport2 = "Employee_Summary_2"

Response1 = MsgBox("Would the print in color ?" _
& vbCr & vbCr & " Press ""Yes"" to print in Color" _
& vbCr & " Press ""No"" to print in Grayscale", _
vbYesNoCancel + vbQuestion, "Print Options")

If Response1 = vbYes Then
intCopies = InputBox("Please enter number of copies", "Copies")
DoCmd.OpenReport StrReport1, acPreview
DoCmd.PrintOut acPages, 1, 1, , intCopies, True
DoCmd.Close acReport, "Employee_Summary_1"
DoCmd.OutputTo acOutputReport, StrReport1, acFormatPDF, "c:\temp\" & StrReport1 & ".pdf"
ElseIf Response1 = vbNo Then
intCopies = InputBox("Please enter number of copies", "Copies")
DoCmd.OpenReport StrReport2, acPreview
DoCmd.PrintOut acPages, 1, 1, , intCopies, True
DoCmd.Close acReport, "Employee_Summary_2"
DoCmd.OutputTo acOutputReport, StrReport2, acFormatPDF, "c:\temp\" & StrReport2 & ".pdf"
Exit_Command66_Click:
Exit Sub

Err_Command66_Click:
MsgBox Err.Description
Resume Exit_Command66_Click
End If

RE: Help! I need to output first page only.

I would add a control in a Page section that displays the page. Then try to add some code in the On Page event that would cancel the printing if the Page was greater than 1. I haven't tried this but it would be my first attempt.

Duane
Hook'D on Access
MS Access MVP

RE: Help! I need to output first page only.

(OP)
Duane,

Thank for replying, I am able to print the first page only of the report but It's the export I am having problems with. Once the print is completed, I then have document exported to a temp folder. When using the "Printout" command I can specify what pages to print, I just can't figure what command to use for "DoCmd.OutputTo acOutputReport" to specify the page output.

Any Ideas?

RE: Help! I need to output first page only.

Did you even try my suggestion "try to add some code in the On Page event that would cancel the printing if the Page was greater than 1"?

Duane
Hook'D on Access
MS Access MVP

RE: Help! I need to output first page only.

(OP)
Let me try tinkering with that and I will see if I can make that work.

RE: Help! I need to output first page only.

I tried adding code to cancel formatting of each section and it seemed to work other than a blank second page

CODE --> vba

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    Cancel = Me.Page > 1
End Sub

Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As Integer)
    Cancel = Me.Page > 1
End Sub
Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As Integer)
    Cancel = Me.Page > 1
End Sub 

Duane
Hook'D on Access
MS Access MVP

RE: Help! I need to output first page only.

(OP)
I have been trying the samething but I get the same error. "An expression you entered is the wrong data type for one of the arguments". It still prints the first page and one blank page but I cannot get the past the error so the output can take place.

RE: Help! I need to output first page only.

(OP)
Duane, I got it to work! I was focusing to much on the report and had overlooked the button which contained an invalid arugment which I was messing around earlier and had forgot to delete it, hence the error message.

Thank you again!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close