Solved

Access DoCmd.OutputTo user selection

Posted on 2011-03-03
6
880 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

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…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

778 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