Solved

I am having trouble Exporting from an Access Table to a Text File - Ihave created an Export Specification that works manually in Access, but my VBA Code Complains with a Run-time error '3442'

Posted on 2006-07-10
6
461 Views
Last Modified: 2012-05-05
I am trying to automate the exporting of some data from a Table to a Test File. The data is actually created by a Query, but because I have some Memo fields of more than 255 characters, I have had to make the Query an Append Query, & my code firstly removes all Rows from the Table, then runs the Query to repopulate the Table.

If I Export the data from this Table manually, it works just fine, using the Export Specification I have created previously. However, if I run my VBA Code, I get the following error:

 "Run-time error '3442':

 In the text file specification 'ExportToTextFile', the ExtendedInfoText option is invalid."

Here is my VBA Code:

 DoCmd.TransferText acExport, "ExportToTextFile", "ExportToTextFile", "\\Ukenetsrv01\clients\Direct.com\Export.txt", True

The ExportToTextFile is the Export Specification I have previously created.

Any idea what's wrong here?

Thanks.
0
Comment
Question by:PaulCutcliffe
  • 3
  • 2
6 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 17073502
Could it possibly be getting confused as your spec and source object have the same name?
Have u tried changing one of the names to something else to see what happens?

0
 

Author Comment

by:PaulCutcliffe
ID: 17073793
Yes, I've tried various names, but the result is the same.
0
 

Author Comment

by:PaulCutcliffe
ID: 17074124
If I remove one of the last two columns (quite big, come from Memo fields), then it exports perfectly, using my same VBA Code.

Are there limits that somehow only apply to these Export Specifications, but only when used in Code?
0
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 38

Accepted Solution

by:
puppydogbuddy earned 250 total points
ID: 17074663
According to Access help, you are supposed to use acExportFixed, acExportDelim, acExportHTML, or acExportMerge as the transfer type.....and presented the following example:

TransferText Method Example
The following example exports the data from the Microsoft Access table External Report to the delimited text file April.doc by using the specification Standard Output:

DoCmd.TransferText acExportDelim, "Standard Output", _
    "External Report", "C:\Txtfiles\April.doc"


Assuming you have a delimited file, your syntax should be:

DoCmd.TransferText acExportDelim, "ExportToTextFile", "ExportToTextFile", "\\Ukenetsrv01\clients\Direct.com\Export.txt", True
0
 

Author Comment

by:PaulCutcliffe
ID: 17077770
puppydogbuddy: Excellent, that works a treat!

I hadn't spotted that, & even if I had, would probably have assumed that I didn't need to specify 'Delimited' there, as I was using an Export Specification that stated it was delimited, & it did work fine with just one less Memo field in.

Anyway, thanks for sorting that. :-)

0
 
LVL 38

Expert Comment

by:puppydogbuddy
ID: 17077878
You are welcome.  Glad I could help.
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Modal form 11 30
Access Crosstab Query with Multiple Values 4 32
unable to create table-based data macro in MS ACCESS 2013 11 25
Run SQL Server Proc from Access 11 30
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

770 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