Solved

Access DoCmd.OutputTo user selection

Posted on 2011-03-03
6
863 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
Comment Utility
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
Comment Utility
<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
Comment Utility
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 10

Author Comment

by:VTKegan
Comment Utility
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
Comment Utility
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
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now