473,378 Members | 1,438 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Why doesn't OutputTo Method prompt for format?

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
5 10241

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
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
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

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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jon Shemitz | last post by:
I'm puzzled by this, code clarified from working code IToolboxService GetToolboxService(IDesignerHost AnyDesigner) { return (IToolboxService) AnyDesigner.RootComponent.Site. GetService(...
7
by: tolisss | last post by:
Hi i have a string like "22/5/2006 12:00:00 pµ" and i want to create a string like "05/22/06" could someone please
8
by: J. D. Leach | last post by:
I am not sure whether this would be considered off topic or not, but here goes.....don't flame me too bad. Running GNU GCC 4.0.1 and GDB 6.3. Was checking my compiler and debugger output prior...
4
by: J Miro | last post by:
When I use ToString method to format the value of a nullable numeric variable, I get "No overload for method 'ToString' takes '1' arguments" error message. Example: Int32? myNum = 12345; ...
2
by: yaru22 | last post by:
When I look at the C++ reference, erase method for map takes an iterator as a parameter. I'm wondering why it takes iterator instead of key value. Wouldn't it be faster to take key value and erase...
3
by: RZ15 | last post by:
Hi, I'm going to be giving many people an access database file with a switchboard with quite a few essential queries (query-by-form) so that they can pull data whenever they want. I have a button...
5
by: phhonl | last post by:
Dim x As String x = Format$("50", "00000000") in vb6 x returns "00000050" in vb.net 2005 x returns "0000000" How do I get the vb6 result in vb.net 2005?
14
by: | last post by:
Hi, I program in asp.net. I have a date in TextBox in format "dd/MM/yyyy". I would like to validate if the date is realy correct. I used RegularExpressionValidator with...
5
by: Angry C sharp user | last post by:
I am currently working on a Windows Forms Application and I need to create a few methods in another class and then call the methods back into my form1.cs but every time I set my global variables...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.