Solved

how can I dynamically specify the output location of an MS ACCESS report

Posted on 2013-05-21
5
297 Views
Last Modified: 2013-06-07
I have a system of about 30 programs - ACCDBs.
They all output reports as PDFs to a fixed location:
C:\myapp\output

How can relocate the myapp folder and have the reports output to the new location such as
h:\myhomedirectory\myapp\output

thanks
Phil
0
Comment
Question by:philkryder
  • 2
  • 2
5 Comments
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 39186520
The output location would have been saved when you created the reports. If the output is generated in VBA, you need to edit it there in each case, if in a macro (possibly in the form you create the report from, edit it there.


Kelvin
0
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 39186935
Along the lines of what Kelvin has posted, our databases have a table called "tblPaths" to store paths like this that are needed in various places in the code.  The fieldnames show the different "types" of paths, and there is a single record containing the actual paths... so the table might look like this:

tblPaths:

FieldName                    Data
---------------------------------------
PDFReportPath             h:\myhomedirectory\myapp\output
webPath                        www.mysite.com
WorkOrderInputFiles   h:\myhomedirectory\myapp\workorders
ImagesPath                  h:\myhomedirectory\myapp\Images

When needed, these paths can be looked up in the code... for example:

Dim strOutputPath as String
Dim strFile as string
strOutputPath = DLookup("PDFReportPath", "tblPaths")
strFile = strOutputPath & "\" & Format(Date,"yyyy_mm_dd_") & "myReport.pdf" 
' Output a report...
DoCmd.OutputTo acOutputReport, "rptMyReportName", acFormatPDF, strFile, True

Open in new window


This allows you to easily change the path for the reports -- just by editing the path as stored in the table.
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 39187152
no points please.  Minor correction to mbizup's code:

strOutputPath = DLookup("Data", "tblPaths", "[FieldName] = 'PDFReportPath'")
0
 
LVL 61

Expert Comment

by:mbizup
ID: 39187181
Dale,

My code was correct... but the explanation may not have been clear.  I used that format because of a lack of horizontal space.  It might be clearer in a code snippet.

tblPaths contains a single record.  The FieldNames in my previous post are the actual columns in that table.  So pictured another way, the DATA in tblPaths is:

PDFReportPath                             webPath                       WorkOrderInputFiles           ImagesPath  
_______________________________________________________________________________________________________________________     

h:\myhomedirectory\myapp\output         www.mysite.com           h:\myhomedirectory\myapp\workorders        h:\myhomedirectory\myapp\Images       

Open in new window

0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 39187193
Miriam,

I get it, your Paths table contains a single record and multiple fields, very "non-normal" of you.  I should have figured that out when I saw the "FieldName" header on your list.

;-)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

735 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