By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,488 Members | 2,545 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,488 IT Pros & Developers. It's quick & easy.

Why doesn't OutputTo Method prompt for format?

P: n/a
When trying to export a table:

DoCmd.OutputTo acOutputTable, "tblOutput", strFile

I get an error:

Error Number 2282: The format in which you are attempting to output the
current object is not available.

The help files states:

If you omit this argument, Microsoft Access prompts you for the output
format.
AcFormat can be one of these AcFormat constants.
acFormatASP
acFormatDAP
acFormatHTML
acFormatIIS
acFormatRTF
acFormatSNP
acFormatTXT
acFormatXLS
I could put option buttons on the form and let the user select which format
and then have code specify the AcFormat, but the help file seem to suggest
that I should receive a prompt...

ALSO - Is there an easy way to export a table into CSV Format ????

Here is the code...

DoCmd.SetWarnings False
DoCmd.RunSQL ("SELECT DISTINCT ... INTO tblOutput FROM ... INNER JOIN ...
WHERE tblEntity.Entity_ID IN (SELECT Entity_ID FROM tblEid)")
DoCmd.SetWarnings True
strFile = "C:\" & DatePart("m", Date) & "-" & DatePart("d", Date) & "-" &
DatePart("yyyy", Date)
DoCmd.OutputTo acOutputTable, "tblOutput", strFile
MsgBox "File saved as:" & vbCrLf & vbCrLf & strFile, vbInformation, " Export
Complete"

Thanks in advance...
Nov 12 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a

deko wrote:
When trying to export a table:

DoCmd.OutputTo acOutputTable, "tblOutput", strFile
DoCmd.OutputTo acOutputTable, "tblOutput",, strFile

You missed a comma.
and then have code specify the AcFormat, but the help file seem to suggest
that I should receive a prompt...

ALSO - Is there an easy way to export a table into CSV Format ????


See TransferText. You can create an import/export definition if you need to
send in other formats.
Nov 12 '05 #2

P: n/a
wow - what a difference a comma makes!

strFile = C:\DatePart("m", Date) & "-" & DatePart("d", Date) & "-" &
DatePart("yyyy", Date)
DoCmd.OutputTo acOutputTable, "tblOutput", , strFile

Is there any way to get the proper extension on the file after export? I
could append it with code if I know what choice was made in the "Output TO'
Dialog.... how do I know if it's htm, xls, doc....?
"Salad" <oi*@vinegar.com> wrote in message
news:3F***************@vinegar.com...

deko wrote:
When trying to export a table:

DoCmd.OutputTo acOutputTable, "tblOutput", strFile
DoCmd.OutputTo acOutputTable, "tblOutput",, strFile

You missed a comma.
and then have code specify the AcFormat, but the help file seem to suggest that I should receive a prompt...

ALSO - Is there an easy way to export a table into CSV Format ????


See TransferText. You can create an import/export definition if you need

to send in other formats.

Nov 12 '05 #3

P: n/a
deko wrote:
wow - what a difference a comma makes!

strFile = C:\DatePart("m", Date) & "-" & DatePart("d", Date) & "-" &
DatePart("yyyy", Date)
DoCmd.OutputTo acOutputTable, "tblOutput", , strFile

Is there any way to get the proper extension on the file after export? I
could append it with code if I know what choice was made in the "Output TO'
Dialog.... how do I know if it's htm, xls, doc....?


I don't know. Since you are prompted at runtime....however, if there is only 1
filename using your strFile naming scheme, you can always check for it with
Dir(). You'd want to pass to dir, the strFile + ".*". If there are
multiples....then before that you would want to do a Dir() and get a list of
all files and then create the file and do a Dir and see which one is new.
Anyway, check out dir.

Nov 12 '05 #4

P: n/a

I ended up just leaving the naming decision to the user - keep it simple...
and that way they are warned of overwrite...

thanks again for the reply - that comma really helped...


I don't know. Since you are prompted at runtime....however, if there is only 1 filename using your strFile naming scheme, you can always check for it with Dir(). You'd want to pass to dir, the strFile + ".*". If there are
multiples....then before that you would want to do a Dir() and get a list of all files and then create the file and do a Dir and see which one is new.
Anyway, check out dir.

Nov 12 '05 #5

P: n/a
deko wrote:
I ended up just leaving the naming decision to the user - keep it simple...
and that way they are warned of overwrite...

thanks again for the reply - that comma really helped...


You are welcome. There is one other option to consider...maybe not now but
later...if you do need to know what kind of file when the user is ready to
create the file display a combo box and ask the format. Then pass the format
to the subroutine or function. IOW, the form that calls the OutputTo has a
combo to display the types.
Nov 12 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.