Results 1 to 7 of 7
  1. #1
    Join Date
    Dec 2011
    Posts
    7

    Unanswered: Save report to file

    I have this code to save a report to file:

    Private Sub Command17_Click()

    Me.Refresh
    On Error GoTo Err_Command17_Click

    Dim stDocName As String

    stDocName = "rptOperator Log"
    DoCmd.OutputTo acReport, stDocName, acFormatPDF, "L:\Operations\Team Managers\" & DatePart("yyyy", Date_of_Log) & " Operator Log\" & Employee_Name & ID & ".pdf"

    Exit_Command17_Click:
    Exit Sub


    Err_Command17_Click:
    MsgBox Err.Descriptionq
    Resume Exit_Command17_Click

    End Sub

    The problem I'm having is that everytime it saves,it saves one file with all the records to pdf not just the current one and it also prints at the same time. all i want is to save the current report displayed on the form with the employee name and file ID on pdf. any help with this matter will be appreciated.
    thanks in advance.

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    There's nothing there that should print the report. To restrict the report, you've got at least 3 options. One is to open the report in preview mode using a technique like this to restrict it:

    Open a second form to the record

    and then output it. The second is to base the report on a parameter query that uses the form to restrict the records returned. The third is to adapt this type of thing:

    Emailing a different report to each recipient

    For outputting, I'd do the third to avoid the overhead of opening the report first but maintain the flexibility of not having parameters in the query.
    Paul

  3. #3
    Join Date
    Dec 2011
    Posts
    7
    Here is a sample of the database, i just left the form that i need print to file.
    Attached Files Attached Files

  4. #4
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Your actual code includes the line

    DoCmd.OpenReport stDocName, acNormal

    which is printing the report.
    Paul

  5. #5
    Join Date
    Dec 2011
    Posts
    7
    got it.
    What is causing the file to save all reports instead of the current one on the form?

  6. #6
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    apply a filter as part of the openreport method
    Google
    I'd rather be riding on the Tiger 800 or the Norton

  7. #7
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Quote Originally Posted by manics View Post
    got it.
    What is causing the file to save all reports instead of the current one on the form?
    You haven't told it to do otherwise. I gave you 3 different ways of doing it in post 2.
    Paul

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •