Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Error on TransferText

Posted on 2003-11-19
3
Medium Priority
?
666 Views
Last Modified: 2012-08-14
I am getting the following error when I try to use the TransferText method:
Method 'TransferText' of object 'DoCmd' failed.  

Does anyone know why I am getting this error??  My code is below....

    Dim strData As String
    Dim objACC As Access.Application

    Set objACC = New Access.Application
    strDB = gdb.Name
    gdb.Close
    objACC.OpenCurrentDatabase strDB

    If Len(Me.txtFileName) = 0 Then
        MsgBox "Text file spec not entered yet"
        Exit Sub
    ElseIf UCase(Right(Me.txtFileName, 4)) <> ".TXT" Then
        Me.txtFileName = Me.txtFileName & ".txt"
    End If
   
    Screen.MousePointer = vbHourglass
    If Me.optOutput(0).Value = True Then
        objACC.DoCmd.TransferText acExportDelim, CStr("Data Label Export"), CStr("LabelCIDSData"), CStr(Me.txtFileName.Text), True
    Else
        objACC.DoCmd.TransferText acExportDelim, "Formatted Label Spec", "LabelCIDSLabels", Me.txtFileName.Text, True
    End If
0
Comment
Question by:vb9666
  • 2
3 Comments
 
LVL 8

Expert Comment

by:ampapa
ID: 9782170
It could be some data in your file doesn't agree with your file spec. Have you tried manually importing your text file into Access?
0
 

Author Comment

by:vb9666
ID: 9787161
I am trying to export to the text file and use the TransferText method.  However, since it will not work, I do not have a text file that has been exported.  How do I look at the file spec??  I did not create it.

Thanks.
0
 
LVL 8

Accepted Solution

by:
ampapa earned 500 total points
ID: 9796251
Sorry, I thought you were importing into not out of Access I should have read more closely.

You can see the specs by going to View/Options and checking Hidden Objects and System Objects. They hide the filespecs for a reason so be careful but you might be able to get some clue as to what might be happening.

This is from the help file:
"SpecificationName  Optional Variant. A string expression that's the name of an import or export specification you've created and saved in the current database. For a fixed-width text file, you must either specify an argument or use a schema.ini file, which must be stored in the same folder as the imported, linked, or exported text file. To create a schema file, you can use the text import/export wizard to create the file. For delimited text files and Microsoft Word mail merge data files, you can leave this argument blank to select the default import/export specifications."

It appears that it should be using the default FileSpec? could be some other issue/installation problem?

Have you tried creating a filespec in order to do the import? Open access and Export your table to a Textfile, when the window opens click on "Advanced" that will allow you create and save a FileSpec. Then use that name when you try your export and see if that works. The filespec becomes a hidden Object and is also then associated with that DB.

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month21 days, 5 hours left to enroll

810 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