OutputTo Method 
Author Message
 OutputTo Method

I want to use the OutputTo method to automate saving the
results of a query to Excel.  I'm able to get this to
work; however, I'd like to get it to prompt me for a file
name.  According to Access Help, if I leave the outputfile
blank, Access should prompt me for the name, but when I
tried this, it does not save it as an Excel sheet; it
saves it as a 0 byte file with an unrecognized format.  If
I put in a specific file name in the code, it works, but
it always has the same name.

This is the code in my module:

Sub CreateTally()

    DoCmd.OutputTo acOutputQuery, "qryDataMrg",
acFormatXLS, True

End Sub

Can someone tell me what I'm doing wrong?

Lee



Tue, 01 Jun 2004 02:06:41 GMT  
 OutputTo Method
Syntax

DoCmd.OutputTo objecttype[, objectname][, outputformat][, outputfile][,
autostart][, templatefile]

Even though you can leave the outpufile blank, you still need to have a
comma.  With your code, it looks for the filename in the variable "True"
which I don't know whether Access evaluates to Null, empty or even -1.

Try

    DoCmd.OutputTo acOutputQuery, "qryDataMrg", _
    acFormatXLS, , True

HTH
Van T. Dinh


Quote:
> I want to use the OutputTo method to automate saving the
> results of a query to Excel.  I'm able to get this to
> work; however, I'd like to get it to prompt me for a file
> name.  According to Access Help, if I leave the outputfile
> blank, Access should prompt me for the name, but when I
> tried this, it does not save it as an Excel sheet; it
> saves it as a 0 byte file with an unrecognized format.  If
> I put in a specific file name in the code, it works, but
> it always has the same name.

> This is the code in my module:

> Sub CreateTally()

>     DoCmd.OutputTo acOutputQuery, "qryDataMrg",
> acFormatXLS, True

> End Sub

> Can someone tell me what I'm doing wrong?

> Lee



Tue, 01 Jun 2004 11:56:46 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Access 97: OutputTo Method

2. Help with outputto method

3. Help with OutputTo SendTo Action/Method - Multi-post

4. This array is fixed or temporarily locked Error with DoCmd.OutputTo

5. OutputTo RTF 88% smaller than regular label report

6. outputto

7. OutputTo Error command or action not available.

8. OutputTo acOutputReport giving error 29013

9. outputTo with variable outpput name

10. DoCmd.OutputTo just stops in Access 2000

11. DoCmd.OutputTo snapshot causes processing to stop

12. Need faster than: DoCmd.OutputTo

 

 
Powered by phpBB® Forum Software