Solved

Save reports in certain directory

Posted on 2014-12-19
7
82 Views
Last Modified: 2014-12-20
How can I default the directory to save reports?  I know I can direct new database to be saved in a certain folder (Access Options, General, Default db folder) but I am wondering if I can save reports in a certain directory without changing the default db directory.  

thank you
0
Comment
Question by:pdvsa
  • 4
  • 2
7 Comments
 
LVL 26

Expert Comment

by:Nick67
Comment Utility
save reports in a certain directory
In what sense, and in what version of Access?
I take it you mean saving them out as PDF files.
What mechanisms are you using now to do that?
0
 

Author Comment

by:pdvsa
Comment Utility
I have 2010.  It is PDF
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
Comment Utility
use this codes

Sub SaveReport()
Dim folderPath As String, strReport As String
strReport = "myReport"
folderPath = SelectFolder()

If folderPath & "" <> "" Then
    DoCmd.OutputTo acOutputReport, strReport, acFormatPDF, folderPath & "\myreport.pdf"
End If
End Sub

Open in new window


code to select the folder

Function SelectFolder() As String
Dim fd As Object, strTitle As String
Set fd = Application.FileDialog(4)
strTitle = "Select Folder"
With fd
    .Filters.Clear
    .AllowMultiSelect = False
    .ButtonName = Left(strTitle, InStr(strTitle, " ") - 1)
    .InitialView = 1
    .Title = strTitle
    If .Show Then
        SelectFolder = .SelectedItems(1)
    End If
End With
End Function

Open in new window

0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

Author Comment

by:pdvsa
Comment Utility
I haven't tested but I know it must be right if Rey responded.   Good enough for me!!
0
 

Author Comment

by:pdvsa
Comment Utility
Rey, I placed the codes on a button on the report.  I do have an error as shown below.  Let me know what you think.  

After I press the button, I select the folder and next is when I get the error.  

thank you

Exporttopdf
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
you have to change "myReport" with the name of your report on this line

strReport = "myReport"
0
 

Author Comment

by:pdvsa
Comment Utility
ahhh.  Works.  Thank you sir...
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now