Solved

Access DoCmd.OutputTo user selection

Posted on 2011-03-03
6
887 Views
Last Modified: 2013-11-28
I have added an export button to one of my forms, and I would like for the user to be able to click the export button, then bring up the output to dialog.

 dialog
Then save the file to predetermined location.

My question is once the user selects the output type they want, how do I specify the correct file extension in code.

This is the code I have now:

        DoCmd.OpenReport "RIF", acViewReport, , "[Main-Master].[IDTag]='" & ID & "'"
        DoCmd.OutputTo acOutputReport, "RIF", , \\servername\Files\" & ID & ?????????
        DoCmd.Close acReport, "RIF"

0
Comment
Question by:VTKegan
  • 3
  • 2
6 Comments
 
LVL 11

Accepted Solution

by:
techhealth earned 250 total points
ID: 35027118
The third parameter is your format choice, and the options are

acFormatASP
acFormatDAP
acFormatHTML
acFormatIIS
acFormatRTF
acFormatSNP
acFormatTXT
acFormatXLS
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 35027345
<No Points wanted>

And if you have Access 2007 (with the PDF Add-in installed) or Access 2010:
acFormatPDF
0
 
LVL 10

Author Comment

by:VTKegan
ID: 35027489
I do not want to hard code a format in

I want the dialog to pop up, but to save the filename as ID.pdf or ID.xls or ID.snp or ID.rtf
0
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
LVL 10

Author Comment

by:VTKegan
ID: 35027509
I want to give the user all of the options and let them choose how they want to export it.  By leaving the third parameter blank it brings up the dialog box (just like I want it to) but as above I want to save the file with a certain extension based on what the user selects.
0
 
LVL 74

Assisted Solution

by:Jeffrey Coachman
Jeffrey Coachman earned 250 total points
ID: 35027538
Just bear in mind that leaving the Output format argument null is supposed to signify that you want the user to use the "Output To Location" dialog box to select the location and the extension.
Hence you would use this:
   
    DoCmd.OutputTo acOutputReport, "RIF"

The key here is that the "Output To Location" dialog box will default to the last used location, so there may no need to hardcore it.

I don't think you can directly detect what format the user selects from the "Output To Format" dialog box.

...you can build your own "Select Format" form (dialog box) that does this though...
0
 
LVL 10

Author Comment

by:VTKegan
ID: 35027779
Yeah I just didn't want to have to create it... lazy me... I was hoping to use the native dialog boxes.

If I do use the default Output To location box, then I have no control over what the filename is saved as.  They could rename it and call it whatever they wanted and also put it wherever they wanted, which is not what I want..

Looks like I will build it myself.

Thanks for the inputs!
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
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…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

840 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