Solved

Access DoCmd.OutputTo user selection

Posted on 2011-03-03
6
895 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

738 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