Question Export to Text File Error

Leigh46137

Registered User.
Local time
Today, 14:01
Joined
Dec 29, 2009
Messages
12
I have an Access Runtime database (Created in version 2007) that exports the results of a query to a text file that gets uploaded to another application.

I have a button that just opens the query for viewing and that works fine. I can scroll through the records and don't get any errors. The query does some lookups, concatenation and calculations, but does not have any selection criteria.

I have another button that runs the export. The code looks like this:
DoCmd.OpenQuery "WebExport"
DoCmd.RunCommand acCmdExportText
DoCmd.Close acQuery, "WebExport"
DoCmd.OpenQuery "WebCategoriesStatusTrue"
DoCmd.Close acQuery, "WebCategoriesStatusTrue"

When I run it, the query opens and the export text wizard opens. I specify the file location and click 'Finish'. Within just a few seconds it pops up an error message: "Data type mismatch in criteria expression." :confused: It is exporting data to a TEXT file. What criteria expression is it choking on?

The code runs fine on my development machine with full Access 2007 and old data. I can't see any problems with the new data on the runtime machine.

Can anyone tell me how to correct this? Or work around it?

I'm not opposed to writing code to create my file, but I can't have strings enclosed in quotation marks. I don't know how to prevent that.
 
Here's something which might be helpful: http://www.dbforums.com/6390529-post84.html

But it's untested in MSAccess 2007. I use this technique quite often though in almost all my apps. Hopefully it will be of some help.

Otherwise (I'm not up-to-speed on 2007), but with prior versions, designing an Export File Specification to then use in an export routine to export the data to a csv/txt file was the route I'd go before I designed the above link. I'm not sure if 2007 still utilizes Export File Specifications offhand.

The thing I like about the above routine is that if a user wants a new query to export, all I need to do is design the query itself. I never design export routines or create reports anymore. I just import the above example forms into my new application.
 
Thanks! The Transfer Text method works! I never knew about that one. :)
 

Users who are viewing this thread

Back
Top Bottom