Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Access DoCmd.OutputTo user selection

Posted on 2011-03-03
6
Medium Priority
?
909 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 1000 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
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
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 1000 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

721 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