Solved

Error on TransferText

Posted on 2003-11-19
3
656 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 125 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

730 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