Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9070759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:45:55+00:00 2026-06-16T17:45:55+00:00

I got the following VBA code from the web a while ago: Private Sub

  • 0

I got the following VBA code from the web a while ago:

Private Sub btnCreatePDF_Click()
    Dim MyPath As String
    Dim MyFilename As String
    MyPath = "D:\reports\"
        MyFilename = "KS1.pdf"
    'Open report preview and auto-save it as a PDF
        DoCmd.OpenReport "Rpt_KS1", acViewPreview
        DoCmd.OutputTo acOutputReport, "", acFormatPDF, MyPath & MyFilename, False 'Change false to true here to auto-open the saved PDF
    'Close the previewed report
        DoCmd.Close acReport, "Rpt_KS1"
End Sub

It was for use in MS Access to create a single pdf of reports (containing up to 30 pages) and works fine for what i needed. However, i now need to split the report into the 30 or so pages and create a pdf for each of the pages. Any idea how this can be done?
I have a ‘username’ in the report or can add a unique ID if this helps to split them etc.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T17:45:56+00:00Added an answer on June 16, 2026 at 5:45 pm

    Use the 4th parameter (WhereCondition) of Docmd.OpenReport. With the WhereCondition, do exactly what you would normally do when adding a Where to your query, only don’t include the word Where. This will make the report only display records that match the WhereCondition.

    Retrieve your list of unique identifiers into some sort of a collection, or recordset then do a loop. This example assumes that you have them in a collection called uniqueIds and will almost definitely require some modification by you.

    Dim MyPath As String
    Dim MyFilename As String
    MyPath = "D:\reports\"    
    'Loop structure may vary depending on how you obtain values
    For each uniqueId in uniqueIds
        MyFilename = "KS1" & uniqueId & ".pdf"
    'Open report preview and auto-save it as a PDF
        DoCmd.OpenReport "Rpt_KS1", acViewPreview, , "uniqueField = " & uniqueID
        DoCmd.OutputTo acOutputReport, "", acFormatPDF, MyPath & MyFilename, False
    'Close the previewed report
        DoCmd.Close acReport, "Rpt_KS1"
    Next uniqueId
    

    Strictly speaking, this may not result in a different PDF for each page. But it will generate a different PDF for each uniqueID, which might be every page depending on your data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got following code from net and it looks everything is proper but i'm
I got following xml code . How to get comment from that xml using
I got following error. java.lang.NullPointerException: lock == null while get json file from server.I
I've got a sheet setup with the following VBA: Sub PrintPDF() Application.DisplayAlerts = False
My problem is I got following encoding error while copying data from csv files
I Got following XML from Amazon Web-Service. <aws:UrlInfoResponse> <aws:Response> <aws:OperationRequest> <aws:RequestId>8789797</aws:RequestId> </aws:OperationRequest> <aws:UrlInfoResult> <aws:Alexa>
I got following repsonse from a Web service call, I tried to unmarshal the
I got following code in an XHTML-document and every browser saysit is malformed :(
I've got following code in my AsyncTask. The only thing I want the AsyncTask
I have got following code: I have a enum: public enum HardwareInterfaceType { Gpib

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.