Results 1 to 7 of 7
  1. #1
    ekryez is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    May 2014
    Posts
    25

    Save Reports to defined Path in path Field.

    Till now I managed to publish and save all in C:\Reports. What I'm trying to do is Save to path specified in Path. DB attached.
    Private Sub PrintAll_Click()
    Dim db As DAO.Database


    Dim rs As DAO.Recordset
    Dim MyPath As String
    Dim MyFileName As String
    Dim MyProjectNumber As String
    Dim MyProjectName As String

    MyPath = "C:\Reports\"

    Set db = CurrentDb()
    Set rs = db.OpenRecordset("SELECT ProjectNumber,ProjectName FROM Master", dbOpenDynaset)
    With rs
    Do While Not .EOF
    MyProjectNumber = !ProjectNumber
    MyProjectName = !ProjectName
    MyFileName = MyProjectNumber & " " & MyProjectName & ".PDF"
    DoCmd.OpenReport "Total Report", acViewPreview, , "ProjectNumber='" & !ProjectNumber & "'"
    DoCmd.OutputTo acOutputReport, "Total Report", acFormatPDF, MyPath & MyFileName
    DoCmd.Close acReport, "Total Report"
    .MoveNext
    Loop
    End With
    Set rs = Nothing
    Set db = Nothing
    End Sub
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    If you don't want them saved into C:\Report folder, what folder do you want to use? There is no variable Path, only MyPath. So what is Path - a textbox on form?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    ekryez is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    May 2014
    Posts
    25
    Hi June, i have added the Path field in DB.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    In what table - Master?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    ekryez is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    May 2014
    Posts
    25
    Yes the last Field

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    Then change the code to pull the Path field into the recordset:

    Set rs = db.OpenRecordset("SELECT ProjectNumber, ProjectName, Path FROM Master", dbOpenDynaset)

    And use the field to build filepath

    DoCmd.OutputTo acOutputReport, "Total Report", acFormatPDF, !Path & MyFileName
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    ekryez is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    May 2014
    Posts
    25
    Quote Originally Posted by June7 View Post
    Then change the code to pull the Path field into the recordset:

    Set rs = db.OpenRecordset("SELECT ProjectNumber, ProjectName, Path FROM Master", dbOpenDynaset)

    And use the field to build filepath

    DoCmd.OutputTo acOutputReport, "Total Report", acFormatPDF, !Path & MyFileName
    Great works like a charm

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 10
    Last Post: 01-09-2014, 03:00 AM
  2. Replies: 13
    Last Post: 12-12-2013, 07:22 PM
  3. Replies: 3
    Last Post: 11-24-2012, 08:56 AM
  4. back end path
    By Mclaren in forum Programming
    Replies: 1
    Last Post: 06-08-2011, 01:13 PM
  5. not a valid path
    By JJJ in forum Access
    Replies: 0
    Last Post: 03-28-2011, 10:50 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums